Graphics |
Example -- Specifying Ticks and Tick Labels
You can adjust the axis tick-mark locations and the labels appearing at each tick mark. For example, this plot of the sine function relabels the x-axis with more meaningful values.
x = -pi:.1:pi; y = sin(x); plot(x,y) set(gca,'XTick',-pi:pi/2:pi) set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'})
These commands (xlabel
, ylabel
, title
, text
) add axis labels and draw an arrow that points to the location on the graph where y = sin(-pi/4).
xlabel
('-\pi \leq \Theta \leq \pi')ylabel
('sin(\Theta)')title
('Plot of sin(\Theta)')text
(-pi/4,sin(-pi/4),'\leftarrow sin(-\pi\div4)',... 'HorizontalAlignment','left')
Setting Line Properties on an Existing Plot
Change the line color to purple by first finding the handle of the line object created by plot
and then setting its Color
property. Use findobj
and the fact that MATLAB creates a blue line (RGB value [0 0 1]) by default. In the same statement, set the LineWidth
property to 2 points.
The Greek symbols are created using TeX character sequences.
Axis Limits and Ticks | Setting Aspect Ratio |
© 1994-2005 The MathWorks, Inc.