QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
QwtPyPlot Class Reference

Matplotlib pyplot-like interface for Qwt plotting. More...

#include <qwt_pyplot.h>

Inheritance diagram for QwtPyPlot:

Classes

class  PrivateData
 

Public Member Functions

 QwtPyPlot (QwtFigure *figure, QObject *parent=nullptr)
 
 QwtPyPlot (QwtPlot *plot, QObject *parent=nullptr)
 
QwtFiguregcf () const
 
QwtPlotgca () const
 
void sca (QwtPlot *plot)
 
QwtPlotsubplot (int rows, int cols, int index)
 Create a subplot in a grid layout.
 
QwtPlotaddAxes (const QRectF &rect=QRectF(0.1, 0.1, 0.8, 0.8))
 
QwtPlottwinx (QwtPlot *host=nullptr)
 
QwtPlottwiny (QwtPlot *host=nullptr)
 
void tightLayout ()
 
QwtPlotCurveplot (const QVector< double > &y, const QString &fmt=QString(), const QString &label=QString())
 
QwtPlotCurveplot (const QVector< double > &x, const QVector< double > &y, const QString &fmt=QString(), const QString &label=QString())
 
QwtPlotCurveplot (const QVector< QPointF > &data, const QString &fmt=QString(), const QString &label=QString())
 
QwtPlotCurvescatter (const QVector< double > &x, const QVector< double > &y, double size=20, const QString &color=QString(), const QString &label=QString())
 Create a scatter plot (markers only, no lines)
 
QwtPlotBarChartbar (const QVector< double > &values, const QString &color=QString(), const QString &label=QString())
 
QwtPlotBarChartbar (const QVector< double > &x, const QVector< double > &values, double width=0.8, const QString &color=QString(), const QString &label=QString())
 
QwtPlotHistogramhist (const QVector< double > &data, int bins=10, const QString &color=QString(), const QString &label=QString())
 Create a histogram from raw data with automatic binning.
 
QwtPlotBoxChartboxplot (const QVector< QwtBoxSample > &data, const QString &label=QString())
 
QwtPlotIntervalCurvefillBetween (const QVector< double > &x, const QVector< double > &y1, const QVector< double > &y2, const QString &color=QString(), double alpha=0.3)
 Fill the area between two curves.
 
QwtPlotIntervalCurveerrorbar (const QVector< double > &x, const QVector< double > &y, const QVector< double > &yerr, const QString &fmt=QString(), const QString &label=QString())
 Create error bars with symmetric y-error.
 
QwtPlotSpectrogramimshow (const QVector< QVector< double > > &data, const QString &cmap="viridis", double vmin=0.0, double vmax=0.0)
 Display a 2D matrix as a color-mapped image.
 
QwtPlotSpectrogramcontour (const QVector< QVector< double > > &data, const QList< double > &levels={}, const QString &cmap="viridis")
 Draw contour lines from a 2D matrix.
 
QwtPlotVectorFieldquiver (const QVector< double > &x, const QVector< double > &y, const QVector< double > &u, const QVector< double > &v, const QString &color=QString())
 Create a quiver (vector field) plot.
 
QwtPlotTradingCurvecandlestick (const QVector< QwtOHLCSample > &data, const QString &label=QString())
 
QwtPlotGridgrid (bool show=true, bool minor=false)
 
QwtPlotMarkeraxhline (double y, const QString &fmt=QString())
 
QwtPlotMarkeraxvline (double x, const QString &fmt=QString())
 
QwtPlotZoneItemaxhspan (double y1, double y2, const QString &color=QString(), double alpha=0.3)
 
QwtPlotZoneItemaxvspan (double x1, double x2, const QString &color=QString(), double alpha=0.3)
 
QwtPlotArrowMarkerannotate (const QString &text, const QPointF &xy, const QPointF &xytext)
 
QwtPlotLegendItemlegend (const QString &loc="best")
 
void setTitle (const QString &title)
 
void setXLabel (const QString &label)
 
void setYLabel (const QString &label)
 
void setXLim (double min, double max)
 
void setYLim (double min, double max)
 
void setXScale (const QString &scale)
 
void setYScale (const QString &scale)
 
void setXTicks (const QVector< double > &ticks, const QStringList &labels={})
 
void setYTicks (const QVector< double > &ticks, const QStringList &labels={})
 
void invertXAxis ()
 
void invertYAxis ()
 
void setFaceColor (const QString &color)
 
void setAxesColor (const QString &color)
 
void colorbar (QwtPlotSpectrogram *spectro=nullptr)
 
bool savefig (const QString &filename, int dpi=-1)
 
void show ()
 
void enablePan (bool enable=true)
 
void enableZoom (bool enable=true)
 

Detailed Description

Matplotlib pyplot-like interface for Qwt plotting.

QwtPyPlot provides a high-level, stateful API inspired by matplotlib's pyplot module. It wraps a QwtFigure (or a single QwtPlot) and delegates all operations to the existing Qwt infrastructure (QwtPlotFactory, QwtPlotStyling, etc.).

The class maintains a "current axes" pointer (like matplotlib's gca()), so successive calls to plot(), setTitle(), etc. always operate on the active subplot.

Example:
// Create a figure with 2 subplots
QwtFigure* fig = new QwtFigure;
QwtPyPlot plt(fig);
plt.subplot(2, 1, 1);
plt.plot({0, 1, 2, 3}, {1, 4, 2, 5}, "r-o", "Temperature");
plt.setTitle("Sensor Data");
plt.grid(true);
plt.legend();
plt.subplot(2, 1, 2);
plt.bar({10, 20, 30, 40}, "b", "Sales");
plt.savefig("output.png", 300);
fig->show();
A figure container for organizing Qwt plots with flexible layout options.
Definition qwt_figure.h:47
Matplotlib pyplot-like interface for Qwt plotting.
Definition qwt_pyplot.h:113
Single-plot mode:
QwtPlot* plot = new QwtPlot;
QwtPyPlot plt(plot);
plt.plot(x, y, "b--");
plt.scatter(x2, y2, 50, "r");
plot->show();
A 2-D plotting widget.
Definition qwt_plot.h:99
See also
QwtFigure, QwtPlot, QwtPlotFactory, QwtPlotStyling

Member Function Documentation

◆ contour()

QwtPlotSpectrogram * QwtPyPlot::contour ( const QVector< QVector< double > > &  data,
const QList< double > &  levels = {},
const QString &  cmap = "viridis" 
)

Draw contour lines from a 2D matrix.

Parameters
data2D matrix (rows x cols)
levelsContour levels (empty = auto-generate 10 levels)
cmapColor map name
Returns
The created spectrogram with contour mode

◆ errorbar()

QwtPlotIntervalCurve * QwtPyPlot::errorbar ( const QVector< double > &  x,
const QVector< double > &  y,
const QVector< double > &  yerr,
const QString &  fmt = QString(),
const QString &  label = QString() 
)

Create error bars with symmetric y-error.

Parameters
xX coordinates
yY values (center)
yerrError values (symmetric)
fmtFormat string for the center line
labelLegend label
Returns
The created interval curve representing error bars

◆ fillBetween()

QwtPlotIntervalCurve * QwtPyPlot::fillBetween ( const QVector< double > &  x,
const QVector< double > &  y1,
const QVector< double > &  y2,
const QString &  color = QString(),
double  alpha = 0.3 
)

Fill the area between two curves.

Parameters
xX coordinates
y1Upper curve values
y2Lower curve values
colorFill color
alphaFill opacity (0.0-1.0)
Returns
The created interval curve

◆ hist()

QwtPlotHistogram * QwtPyPlot::hist ( const QVector< double > &  data,
int  bins = 10,
const QString &  color = QString(),
const QString &  label = QString() 
)

Create a histogram from raw data with automatic binning.

Parameters
dataRaw data values
binsNumber of bins
colorBar color
labelLegend label
Returns
The created histogram

◆ imshow()

QwtPlotSpectrogram * QwtPyPlot::imshow ( const QVector< QVector< double > > &  data,
const QString &  cmap = "viridis",
double  vmin = 0.0,
double  vmax = 0.0 
)

Display a 2D matrix as a color-mapped image.

Parameters
data2D matrix (rows x cols)
cmapColor map name ("viridis", "hot", "cool", "jet", "gray")
vminMinimum value for color scaling (0 = auto)
vmaxMaximum value for color scaling (0 = auto)
Returns
The created spectrogram

◆ quiver()

QwtPlotVectorField * QwtPyPlot::quiver ( const QVector< double > &  x,
const QVector< double > &  y,
const QVector< double > &  u,
const QVector< double > &  v,
const QString &  color = QString() 
)

Create a quiver (vector field) plot.

Parameters
xX positions
yY positions
uX components of vectors
vY components of vectors
colorArrow color
Returns
The created vector field

◆ scatter()

QwtPlotCurve * QwtPyPlot::scatter ( const QVector< double > &  x,
const QVector< double > &  y,
double  size = 20,
const QString &  color = QString(),
const QString &  label = QString() 
)

Create a scatter plot (markers only, no lines)

Parameters
xX coordinates
yY coordinates
sizeMarker size in points
colorColor name (e.g. "r", "blue", "#ff0000")
labelLegend label
Returns
The created curve

◆ subplot()

QwtPlot * QwtPyPlot::subplot ( int  rows,
int  cols,
int  index 
)

Create a subplot in a grid layout.

Parameters
rowsNumber of rows in the grid
colsNumber of columns in the grid
index1-based index of the subplot (row-major order)
Returns
The newly created QwtPlot

The documentation for this class was generated from the following files: