Plotting functions of SCILAB (1)

Source: Internet
Author: User
Plot functions of SCILAB: plot Functions

The most basic is the plot function, which is similar to the plot function in MATLAB.

xdata = linspace(1,10,50);ydata = sin(xdata);plot(xdata, ydata);

For function plotting, you do not need to calculate the ydata in advance. For example, the results drawn in the following example are the same.

plot (xdata, sin);

This also saves some memory usage.

If you only set the general title, you can do this:

title("My Plot");

If you want to set the title of the XY axis, you can do this:

xtitle("This is a Plot", "x axis", "y axis");


The color and line type can be controlled by adding the third parameter to the plot. The legend () function can set labels. For example:

plot(xdata, sin, "o-r");plot(xdata, cos, "*--y");legend("sin", "cos");

Save image

After drawing a picture, you certainly want to save it to a file. SCILAB supports many image formats. Each of the following functions corresponds to an image format.

 

Xs2png

Xs2fig

Xs2pdf

Xs2gif

Xs2svg

Xs2jpg

Xs2ps

Xs2bmp

Xs2emf

XSS 2ppm

 

If we want to save the image of window 0 as PNG, we can execute the following statement.

xs2png(0, "pic.png");

As mentioned above, the number is written in the drawing window. SCILAB can display multiple image windows at the same time, and identify which drawing window is operated by the window number.

Most of the time we want to be able to add a grid to the image, this operation is easy to implement in MATLAB:

Grid on enable Grid

Grid off

 

SCILAB does not have such a statement, but it can be replaced by the following statement.

Enable grid:

set(gca(),"grid",[1 1]);

Close the grid:

set(gca(),"auto_clear",[-1 -1]);
The following figure shows the effect after the grid is Enabled:

Set the word size for the scale on the axis:

xset("font size", 4);

Sadly, the font size of the title is invalid... There is no solution yet.

Set the background color of the image:

xset("background", color);

Here, color is an integer indicating the index in colormap. You can use the getcolor () function to obtain the current colormap.

getcolor();

Set the background color to green

xset("background", 3); 



(To be continued)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.