Re: Regarding Multiple Y-axis plot
Brought to you by:
rathmann
|
From: Gerard V. <ger...@gr...> - 2005-02-12 06:54:18
|
On Fri, 11 Feb 2005 10:39:02 -0600
quanchi smith <qua...@gm...> wrote:
> Hello, all. I'm asking for help regarding plotting multiple curves
> with multiple y-axis. I want to create yLeft3, yLeft2, yRight2,
> yRight3, etc in addition to the 4 axes available(yLeft, yRight, xTop,
> xBottom). If these are created, I'll be able to tie each of my curve
> to a specific y-axis. Any idea and suggestion ??
>
Yes, but I am only going to help you with code if there is a serious
attempt from your side (I am willing to debug a 200 line example, if
you run into problems -- the difference for me is that I'll spent 15
minutes on debugging but about 2 hours on writing everything myself
-- how much do cost 2 hours of your time?).
As I explained in previous replies:
Look at the realtime example how widgets are tucked between the plot
canvas and the axis (QwtScale). Try to do the following:
(1) tuck another QwtScale between the yLeft axis and the canvas.
(2) use
virtual void QwtCurve::draw(
QPainter *p,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
int from = 0, int to = -1);
to plot.
xMap you get from the xBottom QwtScaleDraw.
yMap you get from your extra yLeft1 scale (you must
have it initialized.
You can play with step (1) and (2) independently.
For instance to draw your curve with your map:
class YourPlot: public QwtPlot
{
...
virtual void drawCanvasItems(QPainter *painter, const QRect &rect,
const QwtArray<QwtDiMap> &maps, const QwtPlotPrintFilter &filter) const {
QwtPlot::drawCanvasItems(painter, rect, maps, filter);
// suppose you have some collection with items, like:
// { QwtCurve, QwtDiMap QwtDiMap) }
// from which you get extraCurve, yourXMap, yourYMap.
extraCurve.draw(painter, yourXMap, yourYMap);
}
}
Yes, you will be able to tie curves to your new axes. A possibility
is to use
the QwtCurve class + some extra info + an extra container
instead of
the QwtPlotCurve class
Gerard
PS: adding more than one axis at each side is madness, IMO.
|