Results 1 to 4 of 4

Thread: 2D array data plot!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question 2D array data plot!

    Hi QWT Forumers!

    I'd like to draw 2d array data and it is my first experience with QWT, everything is OK, but the following code is drawing only ONE(last) curve. Dear fellowship, please help !


    Qt Code:
    1. Plot::Plot()
    2. {
    3. setTitle("A Simple QwtPlot Demonstration");
    4. insertLegend(new QwtLegend(), QwtPlot::RightLegend);
    5.  
    6. // Set axis titles
    7. setAxisTitle(xBottom, "x -->");
    8. setAxisTitle(yLeft, "y -->");
    9.  
    10. // Insert new curves
    11. QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
    12. #if QT_VERSION >= 0x040000
    13. cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
    14. #endif
    15. cSin->setPen(QPen(Qt::red));
    16. cSin->attach(this);
    17.  
    18. const int nPoints = 100;
    19. double x[2][nPoints], y[2][nPoints];
    20. for(int j=0; j<2; j++)
    21. {
    22. for(int i=0; i<nPoints; i++)
    23. {
    24. x[j][i] = -3.14 + i*(j+2)*3.14/(nPoints-1);
    25. y[j][i] = sin((j+1)*x[j][i]);
    26. }
    27. }
    28.  
    29. // Create 2d array data
    30. for(int j=0; j<2; j++)
    31. cSin->setData(x[j],y[j],nPoints);
    32.  
    33. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by kahramonj; 18th March 2009 at 18:30.

Similar Threads

  1. Replies: 12
    Last Post: 31st October 2010, 17:08
  2. Spectrogram Plot Hints
    By shargath in forum Qwt
    Replies: 2
    Last Post: 25th February 2009, 11:11
  3. Using a 2d data array to create an image
    By dbrmik in forum Newbie
    Replies: 20
    Last Post: 28th October 2008, 17:22
  4. Replies: 15
    Last Post: 27th May 2008, 01:46
  5. Creating a Pixmap out of an array of data
    By toratora in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2007, 19:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.