summaryrefslogtreecommitdiff
path: root/Tutorial2_Plot
diff options
context:
space:
mode:
Diffstat (limited to 'Tutorial2_Plot')
-rw-r--r--Tutorial2_Plot/Problems/Tut2.pdfbin0 -> 29099 bytes
-rw-r--r--Tutorial2_Plot/Problems/Tut2Problem.csv15
-rw-r--r--Tutorial2_Plot/Scilab_code/Tutorial2_semilog.sce16
-rw-r--r--Tutorial2_Plot/Scilab_code/Tutotial2_multi_plotting.sce41
-rw-r--r--Tutorial2_Plot/Scilab_code/Tutotial2_plot_save.sce21
-rw-r--r--Tutorial2_Plot/Scilab_code/Tutotial2_plot_save_func.sce27
-rw-r--r--Tutorial2_Plot/Scilab_code/Tutotial2_plotting.sce16
-rw-r--r--Tutorial2_Plot/Scilab_code/change_plot_attribs.sci10
8 files changed, 105 insertions, 41 deletions
diff --git a/Tutorial2_Plot/Problems/Tut2.pdf b/Tutorial2_Plot/Problems/Tut2.pdf
new file mode 100644
index 0000000..ddc5da8
--- /dev/null
+++ b/Tutorial2_Plot/Problems/Tut2.pdf
Binary files differ
diff --git a/Tutorial2_Plot/Problems/Tut2Problem.csv b/Tutorial2_Plot/Problems/Tut2Problem.csv
new file mode 100644
index 0000000..53ce715
--- /dev/null
+++ b/Tutorial2_Plot/Problems/Tut2Problem.csv
@@ -0,0 +1,15 @@
+1,1.05E-14,1E-23,8.68735727748734E-16,3.06988472271084E-16
+2,1.05E-14,1E-23,8.68735727748734E-16,3.06988472271084E-16
+3,1.00E-14,3.70119513918373E-17,2.79736087695949E-15,2.80391266864912E-16
+4,3.70E-14,5.65E-14,1.04559200525073E-14,7.3865291428153E-16
+5,3.70E-14,1.4571218255213E-18,7.01651859869889E-15,8.11719142528036E-16
+6,1.00E-15,1.17015966442439E-18,7.7095815167149E-15,2.05292485680238E-13
+7,3.70E-15,3.80212541554568E-19,2.15320675526335E-14,1.19013817278563E-14
+8,3.70E-15,5.85059486105432E-20,1.54664178302948E-14,8.79191968097034E-13
+9,1.11E-14,3.76606511037024E-17,3.26447099775275E-14,7.32859431036281E-13
+10,3.70074341541719E-17,2.42958520611185E-19,3.81298644807883E-14,4.28588268926054E-12
+11,1E-23,1.78899096261478E-18,1.35509320162881E-13,1.01359319772089E-12
+12,1E-23,2.42863790449231E-19,1.71955664104378E-13,3.2126484715214E-13
+13,1.11022302462516E-16,1.68809380852638E-16,6.08815500389293E-13,7.94331887098062E-14
+14,1.11022302462516E-16,3.40508595605121E-16,3.84924467610673E-13,4.54796283179633E-15
+15,1.57009245868378E-16,3.78577179124018E-16,5.2850172570156E-13,1.20783040520019E-11
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