MATLAB Answers

How can I ensure the polar axes lines remain visible after I overlay the polar axes with a contour plot in MATLAB 7.6 (R2008a)?

7 views (last 30 days)
When I execute the following code,
hold on;
n = 6; r = (0:n)'/n; theta = pi*(-n:n)/n;
X = r*cos(theta); Y = r*sin(theta); C = r*cos(2*theta);
I first see an empty polar axes on top of which the contour is drawn. The axes grid lines then become hidden. I would like to know how to make them visible.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Sep 2010
Polar axes created by the POLAR function in MATLAB 7.6 (R2008a) are simply a set of patch, line and text objects drawn in the right regions to make it look like an axis. This is different from the regular non-polar axes grid lines which are not objects in the handle graphics hierarchy and rendered differently. Therefore, when the contour is overlaid on the polar axes, it hides the grid line and text objects underneath it.
To display the axes grid lines and text objects you will need to extract their handles and set their move them to the top of the graphics hierarchy using UISTACK when all other plotting is complete. For example,
hold on
% Extract handles to polar grid lines and text labels
polarline = findobj(gca,'type','line');
polartext = findobj(gca,'type','text');
n = 6; r = (0:n)'/n; theta = pi*(-n:n)/n;
X = r*cos(theta); Y = r*sin(theta); C = r*cos(2*theta);
% Move the polar grid lines to the top
In addition, you could also set the object's EraseMode property to 'xor' which instrucst MATLAB to render them with a color that contrasts whatever is underneath it. Note that the axes grid line colors will no longer be black in all areas.
% Change EraseMode property of objects
For more information on UISTACK, line properties, text properties and displaying contours in polar coordinates, consult the documentation by executing,
doc uistack
doc line_props
doc text_props
web([docroot '/techdoc/creating_plots/f10-2524.html#f10-2674'])

More Answers (0)





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!