Search This Blog

Wednesday, June 06, 2012

How can I change the thickness or line width of lines, axes, edges of a surface/mesh plot, or the edges of a patch?


How can I change the thickness or line width of lines, axes, edges of a surface/mesh plot, or the edges of a patch?


Date Last Modified: Friday, February 24, 2012
Solution ID:   1-15NOI
Product:   MATLAB
Reported in Release:   No Release
Platform:   All Platforms
Operating System:   All OS
 

Subject:

How can I change the thickness or line width of lines, axes, edges of a surface/mesh plot, or the edges of a patch?

Problem Description:

I am unable to change the LineWidth of dashed(--), dotted(.), or dash-dotted (-.) lines in MATLAB for MS-Windows.

Solution:

Axes, lines, surfaces, and patches all have a 'LineWidth' property. The following describes the effect of the 'LineWidth' on each object:

---------Axes--------

Increases with width of all lines forming the X, Y, and Z axes. Note that this will change the thickness of the grid lines and the box around the 2-D plot. If this effect is not desired (i.e. you wish to only change the thickness of the X-axis across the bottom of the plot) you may wish to add a line object to the axes with the desired properties.

---------Line---------

Increases the width of the line. Note that if you are using markers, such as 'x', 'o', '*', '.', etc., you should use the MarkerSize property to adjust the point size of the markers. Setting the LineStyle produces undesired results.



-------Surface-------

Increases the width of the edges.

--------Patch--------

Increases the width of the edges.

---------------------


For example, to increase the size of the border around a patch object, do the following:

h = fill([1 1 2 2],[1 2 2 1],'r');
set(h,'LineWidth',10)
axis([0 3 0 3])

To increase the linewidth of the line object, do the following:

h = line([1 2],[4 7],'linestyle','--')
set(h,'LineWidth',1.2)

To increase the linewidth of a surface object, do the following:

h = surf(peaks)
set(h,'LineWidth',1.5)
Note the following limitation of MS-Windows:

"The specification for the graphics driver function CreatePen states that broken line styles are not supported for line widths greater than one."

No comments:

Post a Comment

Thank you