Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plot in SCILAB

28 views
Skip to first unread message

A Ramesh

unread,
Feb 3, 2002, 5:08:25 AM2/3/02
to
Hi friends,
I am thoroughly confused about the usage of plot, plot2d etc in SCILAB.
I am a MATLAB guy recently shifted to SCILAB camp. I need a help for the
following question.
x1, y1 each size(N1)
x2, y2 each size(N2)
x3, y3 each size(N3)
x4, y4 each size(N4)
now I need an equivalent set of commands in SCILAB, for the following
MATLAB code.

semilogy(x1,y1,':',x2,y2,'--',x3,y3,'-.',x4,y4,'-');
legend('legend-1','legend-2','legend-3','legend-4');
xlabel('bla-blah');
ylabel('bla-bla-blah');

A quick reply is very much appreciated as I couldn't do anything without
this plot.

regards
Ramesh

Bruno Pincon

unread,
Feb 3, 2002, 9:10:38 AM2/3/02
to A Ramesh

The solution for you may be to use the matlab-like plot lib of
Stephane Mottelet
that you will find here :

http://www.dma.utc.fr/~mottelet/myplot.html

I don't know exactly until which level of details the Stephane 's
plotlib
is equivalent to the matlab way but it is possible that your example
work
without any modif with (and so it is much simpler than using native
scilab graphics routines...).


Else may be the following may work (without for the legends which need
further work). The basic pb is that the plot2d may plot several curves
(and then put a legend for each curves) but they must have all the same
number of points which is not the case for you.

// some datas to try
x1 = linspace(0,1,40)';
y1 = exp(x1.^2);
x2 = linspace(0,1,60)';
y2 = exp(2 - x2.^2);
x3 = linspace(0,1,50)';
y3 = exp(1 + x3.^3) ;

style1 = 2; // style > 0 => the curve is plotted with the color number
style
style2 = 3; // if -9 <= style <= 0 then you have some mark
style3 = 4; // for see the colors and marks enter xset() at the scilab
prompt

xbasc() // clear the previus graph
plot2d("nl",x3,y3,style3,"021")
plot2d("nl",x1,y1,style1,"000")
plot2d("nl",x2,y2,style2,"000")
xtitle("The title","the x","the y")

// stay to add the legend with low level scilab graphics instructions

Now if all your "curves" have the same number of points, the following
may work :

xbasc()
plot2d("nl",[x1 x2 x3],[y1 y2 y3],[style1 style2
style3],"121","leg1@leg2@leg3")
xtitle("The title","the x","the y")

BE CAREFUL AND USE column vector for the xi and yi !

hth

Bruno

Matthias Klingel

unread,
Feb 4, 2002, 5:02:19 AM2/4/02
to

> Else may be the following may work (without for the legends which need
> further work). The basic pb is that the plot2d may plot several curves
> (and then put a legend for each curves) but they must have all the same
> number of points which is not the case for you.

What about doing succesive plot2d commands in the ''modern syntax''?
Like

plot2d (x1,y1,style=[1 1],leg='one curve');
plot2d (x2,y2,style=[-1 2],leg='another curve');

Matthias

Bruno Pincon

unread,
Feb 4, 2002, 3:33:15 AM2/4/02
to

Thanks Matthias : I had not looked completly to the news
possibilities and this one is interesting. Finally the
Ramesh 's problem may be solved with native scilab with :

// some datas to try
x1 = linspace(0,1,40)';
y1 = exp(x1.^2);
x2 = linspace(0,1,60)';
y2 = exp(2 - x2.^2);
x3 = linspace(0,1,50)';
y3 = exp(1 + x3.^3) ;

style1 = [2 1];
style2 = [3 2];
style3 = [4 3];

xbasc() // clear the previus graph

plot2d("nl",x3,y3, style3, strf="121", leg="leg3")
plot2d("nl",x1,y1, style1, strf="100", leg="leg1")
plot2d("nl",x2,y2, style2, strf="100", leg="leg2")


xtitle("The title","the x","the y")

// the third curve is the first plotted because this is the curve
// which take the large place

hth

Bruno

Enrico Segre

unread,
Feb 4, 2002, 5:05:04 AM2/4/02
to
just two notes -

a)

Bruno Pincon wrote:
> xbasc() // clear the previus graph
> plot2d("nl",x3,y3, style3, strf="121", leg="leg3")
> plot2d("nl",x1,y1, style1, strf="100", leg="leg1")
> plot2d("nl",x2,y2, style2, strf="100", leg="leg2")
> xtitle("The title","the x","the y")
>
> // the third curve is the first plotted because this is the curve
> // which take the large place

this is not necessary if one takes advantage of the modern strf option
y=8,
i.e.

plot2d("nl",x1,y1, style1, strf="181", leg="leg1")
plot2d("nl",x2,y2, style2, strf="180", leg="leg2")
plot2d("nl",x3,y3, style3, strf="180", leg="leg3")


b) for the real aficionados: in my toolbox there is a wrapper oplot()
such that the same plot can be achieved with

oplot("nl",list(x1,y1,x2,y2,x3,y3),1:3,"181","leg1@leg2@leg3")

cheers, Enrico

0 new messages