1 Attachment(s)
how to set the y-axis width?
Hello,
i am playing with Qwt. Thanks for the great library! I have written an application with one or more plotters. In the first one i will draw a Chart of an financial market. In the plotter below i will draw as example an indicator. Please see the screenshot.
Attachment 13669
How can i set the width of the Y-axis on the right side of the plotter below? :confused:
I would have the same width as the plotter above (with the candle-sticks). I tried so many things with plotter->axisWidget(QwtPlot::yRight)->resize() etc. but nothing work. Thanks for any suggestions!
Best regards,
johno
EDIT: The vertical line is a QwtPlotMarker. I set the position with: plottMarker->setValue(chartPlotter->invTransform(QwtPlot::xBottom, pos.x()), 0); from the plotter above (with the signal: moved(QPoint) from QwtPlotPicker). It works, but it looks crazy because of the different width of the y-axis.
Re: how to set the y-axis width?
Have a look at the plotmatrix example.
Uwe
6 Attachment(s)
Re: how to set the y-axis width?
Thank you Uwe, the plotmatrix example helps me! :)
My solution:
Code:
void MainWindow::updatePlotters(double lowerBound, double upperBound) {
double maxExtent = 0;
double extent = 0;
for(int i = 0; i < currentTrader->plotters.size(); i++) {
currentTrader
->plotters.
at(i
)->setAxisScale
(QwtPlot::xBottom, lowerBound, upperBound
);
scaleWidget
= currentTrader
->plotters.
at(i
)->axisWidget
(QwtPlot::yRight);
scaleDraw = scaleWidget->scaleDraw();
extent = scaleDraw->extent(scaleWidget->font());
if(extent > maxExtent) maxExtent = extent;
scaleDraw->setMinimumExtent(maxExtent);
currentTrader->plotters.at(i)->updateLayout();
currentTrader->plotters.at(i)->replot();
}
}
Added after 16 minutes:
But a small problem still remains. I thought this would go away if the plotter's have the same drawing area/size. It is about the position of the QwtPlotMarker in the lower plotter (indicator-plotter). I set his position with the position of the QwtPlotPicker from the chart-plotter (the main plotter above).
Code:
plotMarker
->setValue
(chartPlotter
->invTransform
(QwtPlot::xBottom, pos.
x()),
0);
It is almost accurate, but on the right and left side it differs a little bit. In the middle it is ok. Any idea? I use QwtPlotMagnifier to zoom in the chart and give the plotter->axisScaleDiv(QwtPlot::xBottom).lowerBound() and upperBound to the other plotters. So far everything works well, expect the position of the QwtPlotMarker in the second (indicator-chart). But i think this has nothing to do with the zoom functionality.
Any idea how I can fix / optimize this? Thanks a lot!
Best regards johno
Added after 20 minutes:
better images:
Attachment 13682
Attachment 13683
Attachment 13684
Re: how to set the y-axis width?
for your information: This problem is now sloved too! I have to set on all plotters: plotter->plotLayout()->setAlignCanvasToScales(false);
Thanks a lot! Great library!! :)