Hi,
I'm experimenting with Qwt for my plotting needs. It's working very well, but I have a question: Is it possible to make a curve plot and a horizontal bar plot from the same set of samples?
E.g. like this:
// Create a test curve
QVector<QPointF> samples;
for (double y = 0.0; y < 1000.0; y += 10.0) {
auto x = 0.1 + 0.08 * std::sin(y / 50.0);
}
// Create a bar chart
auto barChart = new QwtPlotBarChart("Test Bar Chart");
barChart->setSamples(samples);
barChart
->setRenderHint
(QwtPlotItem::RenderAntialiased);
//barChart->setOrientation(Qt::Horizontal);
barChart->attach(this);
// Create a curve
curve->setSamples(samples);
curve->attach(this);
// Create a test curve
QVector<QPointF> samples;
for (double y = 0.0; y < 1000.0; y += 10.0) {
auto x = 0.1 + 0.08 * std::sin(y / 50.0);
samples.append(QPointF(x, y));
}
// Create a bar chart
auto barChart = new QwtPlotBarChart("Test Bar Chart");
barChart->setSamples(samples);
barChart->setXAxis(QwtPlot::xTop);
barChart->setRenderHint(QwtPlotItem::RenderAntialiased);
//barChart->setOrientation(Qt::Horizontal);
barChart->attach(this);
// Create a curve
auto curve = new QwtPlotCurve("Test Curve");
curve->setSamples(samples);
curve->setXAxis(QwtPlot::xTop);
curve->setRenderHint(QwtPlotItem::RenderAntialiased);
curve->attach(this);
To copy to clipboard, switch view to plain text mode
With the above code, I get the result in the attache without_horizontal_alignment.png. If I uncomment the
barChart->setOrientation(Qt::Horizontal)
barChart->setOrientation(Qt::Horizontal)
To copy to clipboard, switch view to plain text mode
line, I get the result in with_horizontal_alignment.png.
If I *also* switch the x / y values in my samples vector, I can get the correct result for the bar chart item (see working.png), but then the curve is wrong.
I'm looking for a way to use the same vector of samples and get the look I want ("vertical" line chart, but "horizontal" bar chart).
Thanks in advance.
without_horizontal_alignment.png:
without_horizontal_alignment.jpg
with_horizontal_alignment.png:
with_horizontal_alignment.jpg
working.png:
working.jpg
Bookmarks