[Scilab-users] Fwd: plotxxyyy

Philipp Mühlmann p.muehlmann at gmail.com
Sun Oct 9 02:58:49 CEST 2016


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 datapointsx1  =
linspace(1,1000,1000);
// each graph has it's own y-axisy1  = x1;y2  = 200*sin(1/20 * x1);y3
= sqrt(x1);
// create fake x-values for y-axisfake_x = zeros(1,length(x1));y1_min
= 0;                             // min-value for y1-axisy1_max = 100;
                          // max value for y1 axis
y2_min = -2;                            // min-value for y2-axisy2_max
= 2;                             // max value for y2 axis
y3_min = 10;                            // min-value for y3-axisy3_max
= 20;                             // max value for y3 axis
// create 2nd x-axis// example: the 1000 datapoints has been taken in
60 secondsx2_min = 0;x2_max = 60;dx2 = x2_max - x2_min + 1x2 =
linspace(x2_min,x2_max,dx2);
// create fake data for x2 axisfake_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 axisa1 = newaxes();plot2d(fake_x, y1);
      // for fake_x = 0 creates a line on the y1-axis
                                            // therefore the fake data
are not visiblea1.children.children.visible = 'off';       // hide
fake graph if nesessary to only show the axesa1.data_bounds =
[0,y1_min;1,y1_max];       // make x-coordinate start at 0 so that
fake data aling with
y-axisa1.axes_visible(1)="off";a1.filled="off";a1.y_location="left";a1.margins
= [0.2 0.2 0.2 0.2];
// create y2 axisa2 =
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 visiblea2.children.children.visible = 'off';       // hide
fake graph if nesessary to only show the axesa2.data_bounds =
[0,y2_min;1,y2_max];       // set x-min to "0"...x_max does not
matter, since x-axis won't be
showna2.axes_visible(1)="off";a2.filled="off";a2.y_location="left";a2.margins
= [0.1 0.2 0.2 0.2];
// create y3 axisa3 =
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 visiblea3.children.children.visible = 'off';       // hide
fake graph if nesessary to only show the axesa3.data_bounds =
[0,y3_min;1,y3_max];       // set x-min to "0"...x_max does not
matter, since x-axis won't be
showna3.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 visiblea4.children.children.visible = 'off';       // hide
fake graph if nesessary to only show the axesa4.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>:

> 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 it's 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 windowa2.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 x3a3.axes_visible(1)="off";
> drawnow()
>
>
>
>
>
>
>
>
>
> 2016-10-06 21:28 GMT+02:00 Jens Simon Strom <j.s.strom at hslmg.de>:
>
>> *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
>> http://lists.scilab.org/mailman/listinfo/users
>>
>>
>
>
> --
> In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.
>
> There we have the salad.
>
>
> _______________________________________________
> users mailing listusers at lists.scilab.orghttp://lists.scilab.org/mailman/listinfo/users
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>


-- 
In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.

There we have the salad.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161009/a17dc74f/attachment.htm>


More information about the users mailing list