plotting problem!

Help
kuchi
2012-06-21
2013-03-15
  • kuchi

    kuchi - 2012-06-21

    Hello,

     
  • kuchi

    kuchi - 2012-06-21

    Hello guys,

    I've got a problem that when I try to plot in realtime that I must press "space" or "return" to get a new point!!!

    Sorry for my english, I hope you understand me?

    Here is the source code:

    #include "stdafx.h"
    #include "plcdemos.h"
    #include <Windows.h>

    PLFLT x; // array for x
    PLFLT y; // array for y

    PLFLT tempx;
    PLFLT tempy;

    int _tmain(int argc, _TCHAR* argv) // MAIN
    {
    int i; // counter variable

    PLFLT xmin, xmax, ymin, ymax; // min and max Values for x and y

    char  ver;

    for(i=0;i<100;i++) // fills x and y arrays with values
    { // in this example y=x^2
    x_= i+1;
    y= (i+1) * (i+1);
    }

    xmin = x;
    xmax = x;
    ymin = y;
    ymax = y;

    plgver( ver ); // Get the current library version number
       
    fprintf( stdout, "PLplot library version: %s\n", ver );

    plinit(); // Initialize PLplot

    plenv(xmin,xmax,ymin,ymax,0,0); // Set up standard window and draw box

    for(i=0;i<100;i++)
    {
    plpoin(i,x,y,0); // Plot a glyph at the specified points

    Sleep(10);

    }
    plclear(); // Clear current (sub)page

    plenv(xmin,xmax,ymin,ymax,0,0);

    for(i=0;i<100;i++)
    {
    tempx=i+1;
    tempy=(i+1) * (i+1);
        plenv(xmin,xmax,ymin,ymax,0,0);
    plpoin(1,tempx,tempy,0);
    Sleep(10);

    }

    plclear();

    plenv(xmin,xmax,ymin,ymax,0,0); // Set up standard window and draw box

    plpoin(100,x,y,0); // Plot a glyph at the specified points

    plend(); // End plotting session
      return 0;
    }

    It seems to be a problem with "plenv(…)"

    Thanks a lot…_

     
  • Cesar M Vieira

    Cesar M Vieira - 2012-06-21

    Hello Kuchi,

    I'm not so familiar with PLplot too, but I have a simple question: is this the whole code? I mean, have you previously defined who is x and x (and so on) before giving values to xmin, xmax, ymin and ymax?

    Regards,

    César.

     
  • kuchi

    kuchi - 2012-06-22

    Hello cesarmv,

    I found a bug in my source code but I still doesnt work. It must be:

    for(i=0;i<100;i++) // fills x and y arrays with values
    { // in this example y=x^2
    x_= i+1;
    y= (i+1) * (i+1);
    }

    The order is ok. I first calculate the values and then I set xmin and so on.

    Greets_

     
  • kuchi

    kuchi - 2012-06-22

    x_ and y

    why can't I see the brackets?_

     
  • Cesar M Vieira

    Cesar M Vieira - 2012-06-22

    Hi Kuchi,

    This loop doesn't make sense for me. To define the 100 components of the array x, you must write

    for(i=0;i<100;i++) {                                        
         x[i]=i+1;
         y[i]=(i+1)*(i+1);
    }
    

    Did you understand that?

    Regards,

    César.

     
  • Cesar M Vieira

    Cesar M Vieira - 2012-06-22

    x  and y 

     
  • Cesar M Vieira

    Cesar M Vieira - 2012-06-22

    Sorry, I think there's a problem to write brackets () here

     
  • Cesar M Vieira

    Cesar M Vieira - 2012-06-22

    Hey Kuchi,

    Can you give me your email? I've copied your code and I've made some modifications, and I'd like to show you.

    Regards,
    César.

     
  • Cesar M Vieira

    Cesar M Vieira - 2012-07-03

    Hello Kuchi,

    Did you solve your problem? Did you see my last reply?

    Regards,

    César.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks