Drawing functions of SCILAB (1)

Source: Internet
Author: User

Plot function plot function of SCILAB

The most important 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 drawing, you do not need to calculate the ydata in advance. For example, the following example shows the same result.

plot (xdata, sin);

This also saves some memory usage.

If you only set the general title, you can perform the following operations:

title("My Plot");

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

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


Color and line type can be controlled by adding a third worker number 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 has a corresponding image format.

 

Xs2png

Xs2fig

Xs2pdf

Xs2gif

Xs2svg

Xs2jpg

Xs2ps

Xs2bmp

Xs2emf

XSS 2ppm

 

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

xs2png(0, "pic.png");

As mentioned above, the form number is written on the drawing form. SCILAB can display multiple image forms at the same time. The form number is used to identify which drawing form is operated today.

Most of the time we want to add a grid to the image. This operation is very 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);

It is very sad, so the font size of the title is invalid... There is no solution yet.

Set the background color of the image:

xset("background", color);

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)


Drawing functions of SCILAB (1)

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.