Experiences with Scilab – 2

Let us try some plotting in Scilab. The default way is the most elementary way that has been introduced with Matlab and its vector language. It uses vectors x and y to plot the data.



The plot is a bit naked in this simple form. It is displayed in a graphics window. There it can be edited. The display program puts the axis to the plot. So it can be zoomed with new coordinates in the graphics window. Of course, this does not mean that the function is known. Too much zoom will therefore show the line segments.


Note the x.^3 in the formula for y. This vectorizes the power operator x^3. If a function is used instead of a vector y this is no longer necessary.

function y=f(x)

You can do the same simple vector plot in EMT. The elementary plot() can be used, but it will not display any grid or coordinates. So we use plot2d(). To get a similar look as Scilab, tan aspect ratio of 4:3 is set, and a special value for the grid style.

>x=linspace(-1,1,200); y=x^3-x;
>aspect(4/3); plot2d(x,y,grid=6):


The plot looks different due to the anti-aliasing. This can be switched off when saving the plot in EMT.


SVG and PS can be saved by Scilab and EMT too. This gives a smoother way to magnify the plot. However, it should be clear that magnification is not the proper answer to scaling. Fonts, point sizes and line widths have to changed too. In fact, being able to magnify without pixelation is a much overrated feature.

For an example of a 3D plot, I found the following code.



The plot can be turned by the user with the mouse. The display seems to be based on OpenGL or some other 3D rendering. The code in EMT is similar. But EMT does currently not use OpenGL. Therefore the type of scenes it can display is somewhat limited. But this is sufficient for many nice plots. For true 3D scenes, Povray can be used from EMT.

>t=linspace(0,2pi,100); s=t'; z=sin(t)*cos(s);
>plot3d(t,s,z,grid=20,scale=[1,1,3], ...
>   fillcolor=[lightblue,blue],zoom=3,>user):


I tried to mimic the default colors of Scilab. In EMT, the default look would be green. The >user statement lets the user turn the plot with the cursor keys.

Scilab allows plots which are very close to the underlying rendering. We already say the genfac3d() command above. Here is a more complicated example, which I found in the net.

my_plot_desc          = "plot3d and use of geom3d";

r = (%pi):-0.01:0;
x = r.*cos(10*r);
y = r.*sin(10*r);


// Plot the surface'

// Add 2d graphics on 3d graphic'
[x1,y1] = geom3d(x,y,z);

// Adjust some plotting parameters'
BackgroundColorId           = color(70,174,255);
current_axe                 = gca();
plot_3d                     = current_axe.children(2);
plot_3d.hiddencolor         = 32;
polyline                    = current_axe.children(1)';;
polyline.foreground         = 8;
current_axe.rotation_angles = [70,47];
current_axe.background      = BackgroundColorId;


It shows that the 3D rendering of Scilab can display scenes with intersecting objects of different type. That is something EMT can only do with Povray currently. In fact, this would be done in EMT in the following way.

>t=linspace(0,2pi,100); s=t'; z=sin(t)*cos(s);
>plot3d("sin(x)*cos(y)",a=0,b=2pi,c=0,d=2pi,n=100, ...
>   grid=10,>hue,>cp,zoom=3):


What is my conclusion? The scene mode of Scilab is capable of very complex scenes. However, the learning curve to do such complex graphics seems to be quite steep. Moreover, the rendering is not on par with libraries like MatPlotlib for Python or even EMT.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.