2D and 3D Plotting Using Scilab: A Comprehensive Guide

Introduction to Scilab

Scilab is a free and open-source software package that provides a flexible environment for numerical analysis, simulation, and data visualization. It offers a wide range of functionalities, including mathematical operations, statistical analysis, signal processing, and much more. One of the standout features of Scilab is its extensive plotting capabilities, allowing users to create professional-looking plots for various purposes.

Getting Started with 2D Plotting

To start creating 2D plots in Scilab, you first need to install the software on your computer. Once installed, you can open the Scilab console and begin executing commands.

To plot a simple 2D graph, you can use the plot function in Scilab. This function takes two arrays of values: one for the x-axis and another for the corresponding y-axis values. For example, consider the following code snippet:

x = 0:0.1:10; // Create an array of x-axis values
y = sin(x);   // Create an array of corresponding y-axis values
plot(x, y);   // Plot the graph

In the above code, we create an array of x-values ranging from 0 to 10 with a step size of 0.1. Then, we compute the corresponding y-values using the sin function. Finally, the plot function is used to generate the 2D plot of the sine wave.

Enhancing 2D Plots

Scilab provides various options to enhance the appearance of 2D plots. You can customize the line style, color, markers, axes labels, and more to create visually appealing visualizations. Let’s look at some commonly used options:

Line Style and Color

You can change the line style and color of a plot using the style parameter in the plot function. For example:

plot2d(x, y, style = 3)// green dashed line

For different color dashed line the number in the style should be positive integer.

Adding Markers

Markers are useful for highlighting specific data points in a plot. Scilab allows you to add markers using the marker parameter in the plot function. you can zero or negative integers as marker. Here’s an example, the marker parameter is set to 'o' to represent circles as markers.


Axis Labels and Title

To make your plot more informative, it’s essential to include appropriate axis labels and a title. You can achieve this using the xlabel, ylabel, and title functions in Scilab. Here’s how you can add labels and a title:

title('Sine Wave');   // Title of the plot
xlabel('Time (s)');   // x-axis label
ylabel('Amplitude');  // y-axis label

By calling these functions with the desired labels and title as arguments, you can annotate your plot effectively.


1.Graph of sine function




3.Plot of sint vs t

image 15

4. Plot t column vs row size

image 17

Venturing into 3D Plotting

Scilab’s plotting capabilities extend beyond the 2D realm. It also provides powerful tools for creating stunning 3D visualizations. To create a 3D plot, you need to use the plot3d function, which requires three arrays: one for the x-axis, one for the y-axis, and one for the z-axis values. Consider the following example:

x = -10:0.1:10;       // Array for x-axis values
y = -10:0.1:10;       // Array for y-axis values
[X, Y] = meshgrid(x, y);
z = sin(sqrt(X.^2 + Y.^2));  // Array for z-axis values

surf(x, y, z);      // Plot the 3D surface
image 3

In the above code, we create grids of x and y values using the meshgrid function. Then, we calculate the z-values based on the x and y values using the desired mathematical function (sin(sqrt(X.^2 + Y.^2)) in this case). Finally, the plot3d function is used to generate the 3D plot of the surface.

Plotting of sphere

image 1
image 2


In this article, we have explored the basics of 2D and 3D plotting using Scilab. We learned how to create simple 2D graphs, customize their appearance with different line styles, colors, and markers, as well as add axis labels and titles. Additionally, we delved into the realm of 3D plotting and discovered how to generate impressive 3D visualizations. By leveraging Scilab’s powerful plotting capabilities, you can effectively present your data and gain valuable insights from your analysis. So, start exploring Scilab’s plotting features and unlock the potential to create captivating plots that stand out in the realm of data visualization.


Leave a Reply