diff options
author | Chayan Bhawal | 2018-10-01 03:21:11 +0530 |
---|---|---|
committer | Chayan Bhawal | 2018-10-01 03:21:11 +0530 |
commit | d70da5e732149071f715e080407aa5c74e3da44a (patch) | |
tree | ab5273a19f600fde8406eb7ad8431196dd8b39ff /Tutorial2_Plot/Scilab_code | |
parent | 20c792454b7757064cb5ced103357bfed42d9b1a (diff) | |
download | scilab-tutorials-d70da5e732149071f715e080407aa5c74e3da44a.tar.gz scilab-tutorials-d70da5e732149071f715e080407aa5c74e3da44a.tar.bz2 scilab-tutorials-d70da5e732149071f715e080407aa5c74e3da44a.zip |
Problems_updated
Diffstat (limited to 'Tutorial2_Plot/Scilab_code')
-rw-r--r-- | Tutorial2_Plot/Scilab_code/Tutorial2_semilog.sce | 16 | ||||
-rw-r--r-- | Tutorial2_Plot/Scilab_code/Tutotial2_multi_plotting.sce | 41 | ||||
-rw-r--r-- | Tutorial2_Plot/Scilab_code/Tutotial2_plot_save.sce | 21 | ||||
-rw-r--r-- | Tutorial2_Plot/Scilab_code/Tutotial2_plot_save_func.sce | 27 | ||||
-rw-r--r-- | Tutorial2_Plot/Scilab_code/Tutotial2_plotting.sce | 16 | ||||
-rw-r--r-- | Tutorial2_Plot/Scilab_code/change_plot_attribs.sci | 10 |
6 files changed, 90 insertions, 41 deletions
diff --git a/Tutorial2_Plot/Scilab_code/Tutorial2_semilog.sce b/Tutorial2_Plot/Scilab_code/Tutorial2_semilog.sce index 833855b..9acc3a6 100644 --- a/Tutorial2_Plot/Scilab_code/Tutorial2_semilog.sce +++ b/Tutorial2_Plot/Scilab_code/Tutorial2_semilog.sce @@ -1,6 +1,7 @@ //This script demonstrate multi-plotting in Scilab clear clc +exec change_plot_attribs.sci; //Import data from file Data = csvRead('/home/chayan/Documents/scilab-tutorials/Tutorial2_Plot/Data/Tut2_data1.csv'); @@ -9,14 +10,19 @@ Data = csvRead('/home/chayan/Documents/scilab-tutorials/Tutorial2_Plot/Data/Tut2 y = Data(:,1); x = [Data(:,4) Data(:,5)] +//Style of plot +style_plot = [1,2] //Figure 1 is a semilog plot -fig1 = figure(); +fig1 = scf(); plot2d(y,x,[1,2],logflag="nl") -legends(['Length of x1','Length of x3'],[1,2],opt="ur",font_size=1); +legends(['Length of x1','Length of x3'],style_plot,opt="ur",font_size=1); +change_plot_attribs('Time','Data','Sample semi-log plot',5,5,3) //Figure 2 is a loglog plot -fig2 = figure(); -plot2d(y,x,[3,-1],logflag="ll") -legends(['Length of x1','Length of x3'],[3,-1],opt="ur",font_size=1); +fig2 = scf(); +plot2d(y,x,style_plot,logflag="ll") +legends(['Length of x1','Length of x3'],style_plot,opt="ur",font_size=1); +change_plot_attribs('Time','Data','Figure2 (loglog)',5,5,3) + diff --git a/Tutorial2_Plot/Scilab_code/Tutotial2_multi_plotting.sce b/Tutorial2_Plot/Scilab_code/Tutotial2_multi_plotting.sce index e149334..ec5b193 100644 --- a/Tutorial2_Plot/Scilab_code/Tutotial2_multi_plotting.sce +++ b/Tutorial2_Plot/Scilab_code/Tutotial2_multi_plotting.sce @@ -1,37 +1,36 @@ -//This script demonstrate multi-plotting in Scilab +//This script demonstrates multi-plotting in Scilab clear clc +exec change_plot_attribs.sci; //Import data from file Data = csvRead('/home/chayan/Documents/scilab-tutorials/Tutorial2_Plot/Data/Tut2_data1.csv'); //Segregate the data into variables -y = Data(:,1); -x = [Data(:,2) Data(:,4)] - -//Fixing the range of plot -//Range is defined by [xmin,xmax,ymin,ymax] -range_of_plot = [-10,1e-05,20,10e-05] +t = Data(:,1); +x = [Data(:,2:4)] //Style of plot -//Stricly positive value represent the color -//Negative or zero value means given curve points are drawn using marks -//For color of marks use polyline property -style_plot = [-1,2] - -//Plotting y versus two data sets -plot2d(y,x,style_plot,rect=range_of_plot); - - -//For labelling axes and adding a title to the plot -xtitle('Plot of Time versus Length_x1 and Length_x3','Time','Length'); +style_plot = [1,2,4] +//Fixing the range of plot +//Range is defined by [xmin,ymin,xmax,ymax] +range_of_plot = [1,-1e-5,15,8e-05]; +//Plotting y versus two data sets +//plot2d(t,x,style_plot); +plot2d(t,x,style_plot,rect=range_of_plot); + +//Font size and labels for legends //For legends "ur" for upper right -//legends(['Length of x1','Length of x3'],[-1,2]); //Default case -//legends(['Length of x1','Length of x3'],[-1,2],opt="ur"); //Position of the legend box -legends(['Length of x1','Length of x3'],[-1,2],opt="ur",font_size=2); //Font size of the legends +legends(['x1','x2', 'x3'],style_plot,opt="ur",font_size=2); + +//Call function to change plot attributes +change_plot_attribs('Time','Data','Data versus Time',5,5,3) +//For thickness of the plots +attrib = gcf(); +attrib.children(2).children(1).children.thickness = 3; diff --git a/Tutorial2_Plot/Scilab_code/Tutotial2_plot_save.sce b/Tutorial2_Plot/Scilab_code/Tutotial2_plot_save.sce index 20a8427..a3da8f3 100644 --- a/Tutorial2_Plot/Scilab_code/Tutotial2_plot_save.sce +++ b/Tutorial2_Plot/Scilab_code/Tutotial2_plot_save.sce @@ -6,13 +6,24 @@ clc Data = csvRead('/home/chayan/Documents/scilab-tutorials/Tutorial2_Plot/Data/Tut2_data1.csv'); //Segregate the data into variables -y = Data(:,1); -x1 = Data(:,2) +t = Data(:,1); +x = Data(:,2) -//Figure 1 is y versus x1 with linewidth = 3 -//fig1 = figure(); +//Ploting the figure. Name of the figure is fig1; +//Use the field Linewidth to specify thickness of the plot fig1 = scf(1); -plot(y,x1,'Linewidth',3); +plot(t,x,'Linewidth',3); + +//Adding title, xlabels and ylabels +//Changing thickness and textsize in plot +attrib_axes = gca(); //Attributes of axes of active handle +attrib_axes.x_label.text = 'Time'; //X-label +attrib_axes.y_label.text = 'Data'; //Y-label +attrib_axes.title.text = 'x versus t'; //Title of the plot +attrib_axes.x_label.font_size = 5; //X_label font size +attrib_axes.y_label.font_size = 5; //Y_label font size +attrib_axes.title.font_size = 5; //Title font size +attrib_axes.font_size = 4; //Font size of x-axis and y-axis //Export Figure 1 as svg file xs2svg(fig1,'plot_y_versus_x1'); diff --git a/Tutorial2_Plot/Scilab_code/Tutotial2_plot_save_func.sce b/Tutorial2_Plot/Scilab_code/Tutotial2_plot_save_func.sce new file mode 100644 index 0000000..d8f9963 --- /dev/null +++ b/Tutorial2_Plot/Scilab_code/Tutotial2_plot_save_func.sce @@ -0,0 +1,27 @@ +//This script demonstrate exporting plots to svg/pdf files +clear +clc + +exec change_plot_attribs.sci; + +//Import data from file +Data = csvRead('/home/chayan/Documents/scilab-tutorials/Tutorial2_Plot/Data/Tut2_data1.csv'); + +//Segregate the data into variables +t = Data(:,1); +x = Data(:,2) + +//Ploting the figure. Name of the figure is fig1; +//Use the field Linewidth to specify thickness of the plot +fig1 = scf(1); +plot(t,x,'Linewidth',3); + +//Call function to change plot attributes +//Arguments (x_label,y_label,title,label_size,title_size,fontsize) +change_plot_attribs('Time','Data','x versus t',7,6,3) + +//Export Figure 1 as svg file +xs2svg(fig1,'plot_y_versus_x1'); + +//Export Figure 2 as pdf file +xs2pdf(fig1,'plot_y_versus_x1'); diff --git a/Tutorial2_Plot/Scilab_code/Tutotial2_plotting.sce b/Tutorial2_Plot/Scilab_code/Tutotial2_plotting.sce index f16018c..5494863 100644 --- a/Tutorial2_Plot/Scilab_code/Tutotial2_plotting.sce +++ b/Tutorial2_Plot/Scilab_code/Tutotial2_plotting.sce @@ -1,4 +1,4 @@ -//This script demonstrate plotting in Scilab +//This script demonstrate basic plot command in Scilab clear clc @@ -6,15 +6,11 @@ clc Data = csvRead('/home/chayan/Documents/scilab-tutorials/Tutorial2_Plot/Data/Tut2_data1.csv'); //Segregate the data into variables -y = Data(:,1); -x1 = Data(:,2); -x2 = Data(:,3); -x3 = Data(:,4); -x4 = Data(:,5); - -//Plotting y versus x1 -plot(y,x1); - +t = Data(:,1); +x = Data(:,2); +//Plotting x versus t +plot(t,x); +xtitle('A x versus t plot','Time','Data') diff --git a/Tutorial2_Plot/Scilab_code/change_plot_attribs.sci b/Tutorial2_Plot/Scilab_code/change_plot_attribs.sci new file mode 100644 index 0000000..68a04bd --- /dev/null +++ b/Tutorial2_Plot/Scilab_code/change_plot_attribs.sci @@ -0,0 +1,10 @@ +function change_plot_attribs(xlab,ylab,caption,labelsize,capsize,fontsize) + attrib_axes = gca(); //Attributes of axes of active handle + attrib_axes.x_label.text = xlab; //X-label + attrib_axes.y_label.text = ylab; //Y-label + attrib_axes.title.text = caption; //Title of the plot + attrib_axes.x_label.font_size = labelsize; //X_label font size + attrib_axes.y_label.font_size = labelsize; //Y_label font size + attrib_axes.title.font_size = capsize; //Title font size + attrib_axes.font_size = fontsize; //Font size of x-axis and y-axis +endfunction |