Hi all,
I want to draw a curve in the plot, the value of the first point is relatively small and the value of the last one is relatively large,
I want to use QwtSplineCurveFitter to make the curve smoother, but the result shows that the curve could not pass the point,
can you help me to solve this problem?

this is my code:
Qt Code:
  1. #include <qapplication.h>
  2. #include <qwt_plot.h>
  3. #include <qwt_plot_curve.h>
  4. #include <qwt_plot_grid.h>
  5. #include <qwt_curve_fitter.h>
  6. #include <qwt_symbol.h>
  7. #include <qwt_legend.h>
  8. #include <qwt_scale_engine.h>
  9.  
  10. int main( int argc, char **argv )
  11. {
  12. QApplication a( argc, argv );
  13.  
  14. QwtPlot plot;
  15. plot.setTitle( "Plot Demo" );
  16. plot.setCanvasBackground( Qt::white );
  17. plot.setAxisScale( QwtPlot::yLeft, 0, 100 );
  18. plot.setAxisScale( QwtPlot::xBottom, 50.0, 0.0 );
  19. plot.insertLegend( new QwtLegend() );
  20. QwtPlotGrid *grid = new QwtPlotGrid();
  21. grid->attach( &plot );
  22.  
  23. QwtPlotCurve *curve = new QwtPlotCurve();
  24. curve->setTitle( "Some Points" );
  25. curve->setPen( QPen( Qt::blue, 1 ) );
  26. curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
  27.  
  28. QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
  29. QBrush( Qt::yellow ), QPen( Qt::red, 1 ), QSize( 2, 2 ) );
  30. curve->setSymbol( symbol );
  31.  
  32. curve->setCurveAttribute(QwtPlotCurve::Fitted);
  33. pCurveFitter->setFitMode(QwtSplineCurveFitter::ParametricSpline);
  34. curve->setCurveFitter(pCurveFitter);
  35.  
  36. QPolygonF points;
  37. points << QPointF( 0.0, 2.58258 ) << QPointF( 0.995469, 6.45643 )
  38. << QPointF( 4.11356, 12.9129 ) << QPointF( 12.565, 19.3693 )
  39. << QPointF( 25.1777, 25.8257 ) << QPointF( 45.1747, 51.6515 )
  40. << QPointF( 50.5358, 77.4772) << QPointF( 53.477, 103.303)
  41. <<QPointF( 54.8972, 129.129) << QPointF( 56.9157, 154.954)
  42. << QPointF( 60.1614, 206.606) << QPointF( 63.6644, 284.083)
  43. << QPointF( 66.3, 361.56) << QPointF( 68.3328, 439.038)
  44. << QPointF( 70.5758, 542.341) << QPointF( 74.1964, 800.598)
  45. <<QPointF( 76.675, 1058.86) << QPointF(78.6658, 1317.11)
  46. << QPointF(81.0151, 1833.63) << QPointF(83.0936, 2608.4)
  47. << QPointF(84.9255, 3899.69) << QPointF(86.8342, 6482.26)
  48. << QPointF(87.3439, 8290.06);
  49.  
  50. curve->setSamples( points );
  51.  
  52. curve->attach( &plot );
  53.  
  54. plot.resize( 600, 400 );
  55. plot.show();
  56.  
  57. return a.exec();
  58. }
To copy to clipboard, switch view to plain text mode 

and the result picture is here:
simpleplot.png