User Tools

Site Tools


gibson:teaching:spring-2016:math445:lecture:scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gibson:teaching:spring-2016:math445:lecture:scripts [2016/02/01 09:11]
gibson [Markers and line styles]
gibson:teaching:spring-2016:math445:lecture:scripts [2016/02/03 13:54] (current)
gibson [Logarithmic plots]
Line 4: Line 4:
 <​code>​ <​code>​
   Matlab scripting   Matlab scripting
-  plot, semilogy, semilogx, loglog +  ​linestyles and plot modifiers: ​ 
-  xlabel, ylabel, title, legend, axis, grid, clf,  +    xlabel, ylabel, title, legend, axis, grid, clf, 
-  linestyles+
   load, save   load, save
-  what, pwd+  ​plot, semilogy, semilogx, loglog 
 +  ​what, who, pwd, ls 
 </​code>​ </​code>​
  
Line 45: Line 45:
  
 <code matlab> <code matlab>
-plotsincos ​   ​ 
- 
 >> plotsincos % execute the plotsincos script >> plotsincos % execute the plotsincos script
 </​code>​ </​code>​
Line 53: Line 51:
 {{ :​gibson:​teaching:​spring-2016:​math445:​sincos.png?​direct&​400 |}} {{ :​gibson:​teaching:​spring-2016:​math445:​sincos.png?​direct&​400 |}}
  
-===== Markers and line styles =====+===== Line styles ​and markers ​=====
  
 The above plotting script used the matlab **linestyle** codes ''​ '​b-'​ ''​ and ''​ '​r-'​ ''​ to generate blue and red curves for $\cos x$ and $\sin x$. Matlab'​s **help** function provides a pretty good description of how line and marker style codes work. The above plotting script used the matlab **linestyle** codes ''​ '​b-'​ ''​ and ''​ '​r-'​ ''​ to generate blue and red curves for $\cos x$ and $\sin x$. Matlab'​s **help** function provides a pretty good description of how line and marker style codes work.
Line 85: Line 83:
     point but does not draw any line.     point but does not draw any line.
  </​code>​  </​code>​
 +
 +===== Plot modifiers =====
 +
 +Some helpful commands for modifying plots
 +
 +<code matlab>
 +xlabel('​foo'​) % add an x label
 +ylabel('​bar'​) % add a y label
 +title('​baz'​) ​ % add a title
 +legend('​first',​ '​second',​ '​third'​) % add a legend with these labels
 +axis on       % turn on axes and ticks (default)
 +axis off      % turn off axes and ticks
 +axis square ​  % make the plot square
 +axis equal    % scale the x and y axes the same
 +axis([xmin xmax ymin ymax]) % force these specific bounds on the axes
 +grid on       % turn on grid markers
 +grid off      % turn off grid markers
 +hold on       % hold the current plot; the next plot will be plotted on top of this one
 +hold off      % release the current plot; the next plot will erase this one
 +clf           % clear figure (erase current plot)
 +figure(2) ​    % open new figure window, numbered 2
 +</​code>​
 +
 +
gibson/teaching/spring-2016/math445/lecture/scripts.1454346702.txt.gz · Last modified: 2016/02/01 09:11 by gibson