2013年3月9日星期六

Qwt 筆記 - 在同一圖表上顯示不同比例的曲線


如果有兩條曲線的 Y 方向的資料範圍相差很大 (例如: 一條是 0-100, 另一條是 0-10000), 假如它們同時顯示同一個圖表上, 那麼我們會看不見範圍小的曲線的變化.
所以我們會用兩個不同的 Y 軸來處理:

QwtPlot *pLogPlot;
QwtPlotCurve *pFirstCurve, *pSecondCurve;
..........
..........
// First curve
pLogPlot->setAxisScale(QwtPlot::yLeft, pFirstCurve->minYValue(), pFirstCurve->maxYValue());
pFirstCurve->setYAxis(QwtPlot::yLeft);
pLogPlot->enableAxis(QwtPlot::yLeft, true);

// Second curve
pLogPlot->setAxisScale(QwtPlot::yRight, pSecondCurve->minYValue(), pSecondCurve->maxYValue());
pSecondCurve->setYAxis(QwtPlot::yRight);
pLogPlot->enableAxis(QwtPlot::yRight, true);
..........
..........

功能說明參考:
QwtPlot::enableAxis
QwtPlot::setAxisScale
QwtPlotItem::setYAxis

沒有留言: