[Scilab-users] Fwd: plotxxyyy

Frieder Nikolaisen Frieder.Nikolaisen at student.hs-rm.de
Mon Oct 10 13:38:01 CEST 2016


Dear Philipp,

thanks for you help. I tried to adopt your Code to my programm. No 
success. There is a prolbem I should have metioned eralier. The time 
between each datapoint has a different time period. So I cant print the 
y-axis over the time and add a a secound x axis for the line of 
document. I might stick to the plotxyyy.

Best regards
Frieder







Am 10.10.2016 09:04, schrieb Philipp Mühlmann:
> Dear Frieder,
>
> one more comment.
>
> Instead of using "foo"-data, it might be more useful to plot each
> graph several times.
>
> Otherwise the y-axes are not assosiated with the data and you have to
> take more care about them.
>
> e.g.:
>
> // display all graph on first x-axis
>
> plot2d(x1,y1);    // and hide the y1-axis
>
> plot2d(x1,y2);    // and hide the y2-axis
> plot2d(x1,y3);    // and hide the y3-axis
>
> // plot the y-axis assosiated with the corresponding data
>
> plot2d(x1,y1);    // and hide the graph and the x1-axis and shift
> y1 to desired locaion
> plot2d(x1,y2);    // and hide the graph and the x1-axis and shift
> y2 to desired locaion
> plot2d(x1,y3);    // and hide the graph and the x1-axis and shift
> y3 to desired locaion
>
> // plot the x2-axis assosiated with the corresponding data
>
> plot2d(x2,y1);    // and hide the graph and the y1-axis and shift
> x2 to desired locaion
>
> best regards,
>
> Philipp
>
> 2016-10-09 2:58 GMT+02:00 Philipp Mühlmann <p.muehlmann at gmail.com
> [7]>:
>
>> OK.
>>
>> Please find attached a sample that might help you.
>>
>> Note:
>> It is possible to draw only an axis without showing the
>> corresponding data.
>> Hence: One can create some "fake" or "foo" data not displaying them,
>> but showing the corresponding axis.
>>
>> so using this principle, you can draw as many axes as you like..and
>> place them where you like.
>>
>> clc();
>> clear(all);
>>
>> // all datashare same x axis
>> // example: there are 1000 datapoints
>> x1 = linspace(1,1000,1000);
>>
>> // each graph has its own y-axis
>> y1 = x1;
>> y2 = 200*sin(1/20 * x1);
>> y3 = sqrt(x1);
>>
>> // create fake x-values for y-axis
>> fake_x = zeros(1,length(x1));
>> y1_min = 0; // min-value for y1-axis
>> y1_max = 100; // max value for y1 axis
>>
>> y2_min = -2; // min-value for y2-axis
>> y2_max = 2; // max value for y2 axis
>>
>> y3_min = 10; // min-value for y3-axis
>> y3_max = 20; // max value for y3 axis
>>
>> // create 2nd x-axis
>> // example: the 1000 datapoints has been taken in 60 seconds
>> x2_min = 0;
>> x2_max = 60;
>> dx2 = x2_max - x2_min + 1
>> x2 = linspace(x2_min,x2_max,dx2);
>>
>> // create fake data for x2 axis
>> fake_y = zeros(1,length(x2));
>>
>> f = figure();
>> f.background = 8;
>>
>> drawlater()
>>
>> plot2d(x1, y1,1);
>> plot2d(x1, y2,2);
>> plot2d(x1, y3,5);
>> a = gca()
>> a.axes_visible(2)="off";
>> a.margins = [0.2 0.2 0.2 0.2];
>>
>> // create y1 axis
>> a1 = newaxes();
>> plot2d(fake_x, y1); // for fake_x = 0 creates a line on the y1-axis
>> // therefore the fake data are not visible
>> a1.children.children.visible = off; // hide fake graph if nesessary
>> to only show the axes
>> a1.data_bounds = [0,y1_min;1,y1_max]; // make x-coordinate start at
>> 0 so that fake data aling with y-axis
>> a1.axes_visible(1)="off";
>> a1.filled="off";
>> a1.y_location="left";
>> a1.margins = [0.2 0.2 0.2 0.2];
>>
>> // create y2 axis
>> a2 = newaxes();
>> c=color("blue");
>> a2.font_color=c;
>> a2.foreground=c;
>> plot2d(fake_x, y2,c); // for fake_x = 0 creates a line on the
>> y2-axis
>> // therefore the fake data are not visible
>> a2.children.children.visible = off; // hide fake graph if nesessary
>> to only show the axes
>> a2.data_bounds = [0,y2_min;1,y2_max]; // set x-min to "0"...x_max
>> does not matter, since x-axis wont be shown
>> a2.axes_visible(1)="off";
>> a2.filled="off";
>> a2.y_location="left";
>> a2.margins = [0.1 0.2 0.2 0.2];
>>
>> // create y3 axis
>> a3 = newaxes();
>> c=color("red");
>> a3.font_color=c;
>> a3.foreground=c;
>> plot2d(fake_x, y3,c); // for fake_x = 0 creates a line on the
>> y3-axis
>> // therefore the fake data are not visible
>> a3.children.children.visible = off; // hide fake graph if nesessary
>> to only show the axes
>> a3.data_bounds = [0,y3_min;1,y3_max]; // set x-min to "0"...x_max
>> does not matter, since x-axis wont be shown
>> a3.axes_visible(1)="off";
>> a3.filled="off";
>> a3.y_location="right";
>> a3.margins = [0.1 0.2 0.2 0.2];
>> a3.axes_reverse = ["on","off","off"]; // reverse x3 axis, since it
>> is on the right side
>>
>> // create 2nd x-axis
>>
>> a4 = newaxes();
>> c=color("black");
>> a4.font_color=c;
>> a4.foreground=c;
>> plot2d(x2, fake_y,c); // for fake_y = 0 creates a line on the
>> x2-axis
>> // therefore the fake data are not visible
>> a4.children.children.visible = off; // hide fake graph if nesessary
>> to only show the axes
>> a4.data_bounds = [min(x2),0;max(x2),1];
>> a4.axes_visible(2)="off";
>> a4.filled="off";
>> a4.x_location="bottom";
>> a4.margins = [0.2 0.2 0.2 0.1];
>>
>> drawnow()
>>
>> 2016-10-09 1:04 GMT+02:00 Frieder Nikolaisen
>> <Frieder.Nikolaisen at student.hs-rm.de [6]>:
>>
>>> Dear Philipp,
>>>
>>> thank you, thats great. I will try it at work on monday. Actually,
>>> I do have three plots sharing a common x axis and having three
>>> different y axis. Why I do want to have two x axis is, to show to
>>> different times on x. Once in secound, once in line of document.
>>>
>>> Best regards
>>>
>>> Frieder
>>>
>>> Am 08.10.2016 um 23:43 schrieb Philipp Mühlmann:
>>>
>>>> Dear Frieder,
>>>>
>>>> I understand following:
>>>>
>>>> You want to plot 3 graphs into one diagram.
>>>>
>>>> Basically each graph has its own x and y axis.
>>>>
>>>> Since for two graphs the x-axis are the same, you want to have a
>>>> diagram with two x-axis and three y-axis  
>>>>
>>>> Please find a code snipplet that will create such a diagram.
>>>>
>>>> Best regards,
>>>> Philipp
>>>>
>>>> clc();
>>>> clear(all);
>>>>
>>>> x1 = linspace(1,10,10);
>>>> x2 = linspace(0,100,101);
>>>> x3 = x1;
>>>>
>>>> y1 = linspace(1,10,10);
>>>> y2 = sin(x2);
>>>> y3 = sqrt(x1);
>>>>
>>>> drawlater()
>>>>
>>>> plot2d(x1, y1);
>>>> a1 = gca();
>>>> a1.x_location = "bottom";
>>>> a1.y_location = "left";
>>>> a1.margins = [0.2,0.2,0.2,0.2]
>>>>
>>>> // Axis y2
>>>>
>>>> a2=newaxes();
>>>> c=color("blue");
>>>> plot2d(x2,y2,style = c);
>>>> a2.font_color=c;
>>>> a2.foreground=c;
>>>>
>>>> a2.filled="off";
>>>> a2.x_location="bottom";
>>>> a2.y_location="right";
>>>> a2.margins = [0.2,0.2,0.2,0.1]; // shift axis relative to
>>>> graphic window
>>>> a2.data_bounds = [0,-2.;100,2]; // change axis bounds, so that
>>>> graph is nicely placed in plotted area
>>>>
>>>> // Axis y3
>>>>
>>>> a3=newaxes();
>>>> c=color("red");
>>>> plot2d(x3,y3,style = c);
>>>> a3.font_color=c;
>>>> a3.foreground=c;
>>>> a3.filled="off";
>>>> a3.x_location="bottom";
>>>> a3.y_location="left";
>>>>
>>>> a3.data_bounds = [0,1;10,4];
>>>> a3.margins = [0.134 0.2 0.2 0.2];
>>>>
>>>> // display x3 to check overlapping of x1 and x3 tics;
>>>> // if overlapping is good enough, than hide x3
>>>> a3.axes_visible(1)="off";
>>>>
>>>> drawnow()
>>>>
>>>> 2016-10-06 21:28 GMT+02:00 Jens Simon Strom <j.s.strom at hslmg.de
>>>> [3]>:
>>>>
>>>>> EDIT IN #3
>>>>>
>>>>> Am 06.10.2016 18:20, schrieb Jens Simon Strom:
>>>>>
>>>>>> Hallo Frieder,
>>>>>> You ask  many questions in one post.
>>>>>>
>>>>>> 1: You just divide the (numerical)  time interval into an
>>>>>> adequate number of points (which can be neatly accommodated)
>>>>>> with linspace or : and plot the corresponding time text
>>>>>> colums via a for-loop. There is no need that text times
>>>>>> coincide with measured data. They only should be placed at
>>>>>> the correct locations.
>>>>>>
>>>>>> 3:You may not be familiar with how to get quick help from
>>>>>> Scilab: Just highlight the command plot2d or style here and
>>>>>> go to the help pages BY RIGHT MOUSE CLICK.
>>>>>>
>>>>>> 4: Highlight newaxes,  foreground
>>>>>>
>>>>>> 5: I would postpone integrating a checkbox until everything
>>>>>> else is to your satisfaction. The rest of #5 is perhaps
>>>>>> answered by #1.
>>>>>>
>>>>>> General remarks
>>>>>>
>>>>>> *  Do not ask many questions simultaneously. Attack them
>>>>>> one by one. You make it easier for yourself and the helpers.
>>>>>> * Accompany your questions by short examples which omit 
>>>>>> irrelevant ornaments. The code you really write with the
>>>>>> variables you really use is less appropriate in most
>>>>>> cases. 
>>>>>> * Begin to polish the results (color, line types, fonts,
>>>>>> fontsize, etc.) only as the last step in your work. At the
>>>>>> beginning accept what Scilab delivers to you.
>>>>>> * Work the help pages.
>>>>>>
>>>>>> My painful experience is that the polishing job often
>>>>>> consumes more time (and nerves) than the technical problem
>>>>>> itself. Scilab is far from intuitive in that respect.
>>>>>>
>>>>>> Kind regards, Jens
>>>>>>
>>>>>>  
>>>>>
>>>>> _______________________________________________
>>>>> users mailing list
>>>>> users at lists.scilab.org [1]
>>>>> http://lists.scilab.org/mailman/listinfo/users [2]
>>>>
>>>> --
>>>>
>>>> In Kanada is ka na da. Sonst wär Kanada Jemanda.
>>>>
>>>> There we have the salad.
>>>>
>>>> _______________________________________________
>>>> users mailing list
>>>> users at lists.scilab.org
>>>> http://lists.scilab.org/mailman/listinfo/users
>>>
>>> _______________________________________________
>>> users mailing list
>>> users at lists.scilab.org [4]
>>> http://lists.scilab.org/mailman/listinfo/users [5]
>>
>> --
>>
>> In Kanada is ka na da. Sonst wär Kanada Jemanda.
>>
>> There we have the salad.
>
> --
>
> In Kanada is ka na da. Sonst wär Kanada Jemanda.
>
> There we have the salad.
>
> Links:
> ------
> [1] mailto:users at lists.scilab.org
> [2] http://lists.scilab.org/mailman/listinfo/users
> [3] mailto:j.s.strom at hslmg.de
> [4] mailto:users at lists.scilab.org
> [5] http://lists.scilab.org/mailman/listinfo/users
> [6] mailto:Frieder.Nikolaisen at student.hs-rm.de
> [7] mailto:p.muehlmann at gmail.com




More information about the users mailing list