Plotting functions of SCILAB (2)

Source: Internet
Author: User

A graph consists of many elements. Including the graph title, X axis label, Y axis label, and dial line. Figure 1 shows one element.


All these elements can be controlled by code in SCILAB.

Title

In the previous note, we introduced how to use the xtitle () function to add titles to a graph. For example:

title("My Plot"); 

In fact, the title function has three forms:

Title (my_title)

Title (my_title, <property>)

Title (<axes_handle>, <my_title>, <property>)

 

The last time is just the simplest form. You can use the second form to set the font, font size, and other attributes of the title. The following is an example:

x = 0:0.1:10;plot(x, sin);title("$f=sin(x)$","fontname","helvetica bold", "fontsize", 4, "color", "red");


In the above example, "$ F = sin (x) $" is a latex code snippet. SCILAB supports the basic latex mathematical model, so it can produce beautiful titles.

The font is Helvetica Bold, the font size is 4, and the color is red. You can also set other parameters. For more information, see the help documentation.

 

The label of the X axis and the label of the Y axis have two independent functions to set. The usage of these two functions is basically the same as that of the title function. The following is an example:

x = linspace(-5,5,51);y = 1 ./(1+x.^2);plot(x,y,'o-b');xlabel("$-5\le x\le 5$","fontsize",4,"color","red");ylabel("$y(x)=\frac{1}{1+x^2}$","fontsize",4,"color","red");title("Runge function (#Points ="+string(length(x))+").","color","red","fontsize",4);


In addition, both the title and label can be multiline, and the preceding example is slightly modified.

xlabel(["$-5\le x\le 5$";"Second Line"],"fontsize",4,"color","red");ylabel(["$y(x)=\frac{1}{1+x^2}$";"Second Line"],"fontsize",4,"color","red");title(["Runge function (#Points ="+string(length(x))+").";"Second Line"],"color","red","fontsize",4);


If there are multiple curves, you need a legend to describe which curve is what. See the following example:

x = linspace(-5.5,5.5,51);y = 1 ./(1+x.^2);plot(x,y,'ro-');plot(x,y.^2,'bs:');xlabel(["x axis";"(independent variable)"],"fontsize", 4);ylabel("y axis","fontsize", 4);title("Functions","fontsize", 4);legend(["Functions #1";"Functions #2"])

The font and font size of legend cannot be set as the label. After the experiment, we found that legend and the words on the scale share a set of control commands:

xset("font size", 4); 



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.