**Latex** makes possible to write equations in a mathematical format, by using all the symbols and characters specific to mathematics language. Scilab allows the usage of Latex formatted text, in the plot related functions, such as: `xlabel()`

, `ylabel()`

, `title()`

, `legend()`

and `xstring()`

.

In order to input Latex instructions, for any of the Scilab plot related functions, the user has to use the dollar `$`

sign. This is placed in the string argument of the function, at the beginning and the end of the string. For example, in order to input the Greek character α as the x-axis label, we need to write:

`xlabel('$\alpha$')`

Let’s take as example two random functions *f _{1}(α)* and

*f*, defined as:

_{2}(α)f_1(\alpha)=sin(\alpha)-\frac{1}{1+\sqrt{\alpha}}\\

f_2(\alpha)=cos(\alpha)+\frac{1}{1+\sqrt{\alpha}}

\end{split} \end{equation*} \]

The Scilab instructions below generates a vector for the angle *α* between *0* and *2π*. The functions are then evaluated for all values of *α*. Both functions are plotted function of the value of the angle.

alpha = [0:0.01:2*%pi]; f1=sin(alpha)-1 ./(1+sqrt(alpha)); f2=cos(alpha)+1 ./(1+sqrt(alpha)); plot(alpha, f1) plot(alpha, f2, 'r') xgrid xlabel('$\alpha \quad [\text{rad}]$','fontsize',4) ylabel('$f(\alpha)$','fontsize',4) legend('$\Large{f_1(\alpha)}$','$\Large{f_2(\alpha)}$',1) title(['Plot of the functions ' '$f_1(\alpha)$' ' and ' '$f_2(\alpha)$'],'fontsize',3) xstring(1,1,'$\LARGE{sin(\alpha) - \frac{1}{1+\sqrt{\alpha}}}$') xstring(0.15,-1.15,'$\LARGE{cos(\alpha) + \frac{1}{1+\sqrt{\alpha}}}$')

By running the above Scilab instructions in a script file (`*.sce`

), we’ll get the following graphical window:

As you can see, we’ve used **Latex** instructions for all text annotations functions of the plot: `xlabel()`

, `ylabel()`

, `legend()`

, `title()`

and `xstring()`

.

We can combine normal text with Latex text by entering them as a vector of strings. This technique can be seen in the `title()`

function, with the string vector:

`['Plot of the functions ' '$f_1(\alpha)$' ' and ' '$f_2(\alpha)$']`

The `xstring()`

function allows the user to place any text in the graphical window, by specifying the *x,* *y* coordinates and the text to be displayed.

Scilab allows to usage of Latex syntax in all the plot related **string functions**. With this feature, the user can format the images to display complex mathematical equations together with the line plot.

For any questions or observations regarding this tutorial please use the comment form below.

Don’t forget to Like, Share and Subscribe!