Results 1 to 4 of 4

Thread: Strange lines in beginner plot...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2011
    Location
    Jena, Germany
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Strange lines in beginner plot...

    Hi,

    first post, so please don't be too strict with me.

    I'm biologist, not programmer, and it took me a while to get to this point. Now I'm stuck with a problem which I think is easy for a qwt-advanced. One of my final goals is to visualize data from an ad-converter with qwt. For getting accustomed with matters I tried to produce a simple plot with code I found somewhere (in a header?), but when I compile it, I find strange lines besides the curves I would expect:

    Qt Code:
    1. class vtPlot : public QwtPlot
    2. {
    3. Q_OBJECT
    4. static int const NPOINTS = 150;
    5. double x[NPOINTS], ysin[NPOINTS], ycos[NPOINTS];
    6.  
    7. public:
    8. explicit vtPlot(QObject *parent = 0);
    9. void *myData();
    10. QwtPointArrayData *myArray[2];
    11. };
    12.  
    13. vtPlot::vtPlot(QObject *parent)
    14. {
    15. }
    16.  
    17. void *vtPlot::myData()
    18. {
    19. for(int i = 0; i < NPOINTS; i++)
    20. {
    21. x[i] = 0.1*i;
    22. ysin[i] = sin(x[i]);
    23. ycos[i] = cos(x[i]);
    24. }
    25. myArray[0] = new QwtPointArrayData(x,ysin,(sizeof(x)+sizeof(ysin))); // actually not sure if the third argument is correct
    26. myArray[1] = new QwtPointArrayData(x,ycos,(sizeof(x)+sizeof(ycos)));
    27. }
    28.  
    29.  
    30. int main(int argc, char *argv[])
    31. {
    32. QApplication a(argc, argv);
    33. MainWindow w;
    34.  
    35. vtPlot *myPlot = new vtPlot(&w);
    36. QwtPlotCurve *curve1 = new QwtPlotCurve("sinus");
    37. QwtPlotCurve *curve2 = new QwtPlotCurve("cosinus");
    38.  
    39. myPlot->myData();
    40.  
    41. curve1->setData(myPlot->myArray[0]);
    42. curve1->attach(myPlot);
    43.  
    44. curve2->setData(myPlot->myArray[1]);
    45. curve2->attach(myPlot);
    46.  
    47. myPlot->setTitle("Voltage [mV] - Time [s]");
    48. myPlot->setAxisTitle(myPlot->yLeft,"Voltage [mV]");
    49. myPlot->setAxisTitle(myPlot->xBottom,"Time [s]");
    50.  
    51. w.setCentralWidget(myPlot);
    52.  
    53. w.show();
    54.  
    55. return a.exec();
    56. }
    To copy to clipboard, switch view to plain text mode 

    Gives me this:
    graph.jpg

    Of course I ensure having searched the forum and the www for help, but I wasn't successful.
    Any hint would be appreciated.

    Thanks a lot,
    Emi
    Last edited by emigrand; 6th December 2011 at 23:02.

Similar Threads

  1. Replies: 4
    Last Post: 11th May 2011, 19:15
  2. Replies: 3
    Last Post: 18th June 2010, 13:18
  3. plot with hor. lines and text
    By hugo vanwoerkom in forum Qwt
    Replies: 2
    Last Post: 10th March 2010, 17:00
  4. Help! about Qt for beginner!!
    By Cantora in forum Newbie
    Replies: 9
    Last Post: 2nd April 2009, 00:11
  5. Replies: 7
    Last Post: 22nd September 2008, 22:05

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.