www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/PolarAxesColorAndFontSizeExample.m

    %% Polar Axes Color and Font Size
% This example shows how to specify the colors and line width for grid
% lines in polar axes. It also shows how to specify the colors and font
% size for the labels.

%% Create Polar Plot
% Plot a line in polar coordinates. Specify the width of the line as 2
% points.
theta = linspace(0,2*pi);
rho = 2*theta;
figure
polarplot(theta,rho,'LineWidth',2);

%% Font Size and Line Width
% Assign the polar axes object to the variable |pax|. Use |pax| to access
% properties of the polar axes object. Set the font size, font weight, and
% line width for the polar axes object.
pax = gca;
pax.FontSize = 12;
pax.FontWeight = 'bold';
pax.LineWidth = 2;

%% _theta_-Axis Grid Line and Label Color
% Change the color of the _theta_-axis grid lines and labels. Set the color
% using either a character vector of a color name, such as |'blue'|, or an
% RGB triplet. An RGB triplet is a three-element row vector whose elements
% specify the intensities of the red, green, and blue components of the
% color. The intensities must be in the range [0,1], for example, [0.4 0.6
% 0.7].

pax.ThetaColor = 'blue';

%% _r_-Axis Grid Line and Label Color
% Change the color of the _r_-axis grid lines and labels. Set the color
% using either a character vector of a color name or an RGB triplet.

pax.RColor = [0 .5 0];


%% Grid Line Color
% Change the color of all the grid lines to red, without affecting the
% polar axes outline and labels.

pax.GridColor = 'red';

%%
% When you specify the |GridColor| property, the |GridColorMode| property
% changes to |'manual'|. As a result, the |ThetaColor| and |RColor|
% properties no longer affect the grid lines. If you want the |ThetaColor|
% and |RColor| properties to affect the grid lines, then set the
% |GridColorMode| property back to |'auto'|.