%% Customizing Polar Axes
% This example shows how to create, display, and modify polar axes in MATLAB®.
%
%% Polar Axes Objects
% Plot a line representing r = 2 + sin(2\pi\theta) in polar coordinates. Use the polarplot function to plot rho against values of theta. Adjust the polar axes limits using the rlim and thetalim functions.

theta = 0:0.01:10*pi;
rho = 2 + sin(2*pi*theta);

figure
polarplot(theta,rho) 
rlim([0 4])
thetalim([0 180])

%
% The gca function returns the current axes for the current figure. You can view and modify properties of the polar axes object, similar to other graphics properties. The output display of ax shows common polar axes properties.

ax = gca

%
%% Access Individual Polar Axes Properties
% You can access individual properties using the dot notation syntax, object.PropertyName. For example, return the r-axis limits using the RLim property.

rLimits = ax.RLim

%
%% Change Polar Axes Properties
% You can change additional properties of the polar axes using the dot notation syntax, object.PropertyName. For example, specify the location of the r-axis labels and remove the r-axis grid. Also, change properties of the theta-axis including the units, zero degree location, and direction.

ax.RAxisLocation = 0;    
ax.RGrid = 'off'; 
ax.ThetaAxisUnits = 'radians';
ax.ThetaZeroLocation = 'left';
ax.ThetaDir = 'clockwise';

%
%% Visualize Polar Data on a Compass
% When visualizing geographic or location based data, you might want to plot on a polar axes which represents a compass. You can modify several polar axes properties to resemble a compass. For example, create a polar scatter plot with the polarplot function by specifying circles 'o' as the marker type.

rng('default')
theta = 0:0.2:4*pi; 
rho = cos(2*pi*theta) + rand(size(theta));
polarplot(theta,rho,'o')

%
% You can adjust the tick locations of the theta-axis to represent positions of the cardinal directions, specified in the vector pos. Change the zero location of the theta-axis to the top and the direction, ThetaDir, to clockwise. Change the tick labels on the theta-axis and remove the tick labels on the r-axis.

ax = gca;
ax.ThetaTick = 0:45:360;
ax.ThetaZeroLocation = 'top';
ax.ThetaDir = 'clockwise';
ax.ThetaTickLabels = {'N','NE','E','SE','S','SW','W','NW'};
ax.FontWeight = 'bold';
ax.RTickLabel = [];

%
%% Display All Polar Axes Properties
% Polar axes objects in MATLAB have a number of properties. To see all the properties of an object, use the get command.

get(ax)

% Copyright 2012 The MathWorks, Inc.