This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Customizing Polar Axes

This example shows how to create, display, and modify polar axes in MATLAB®.

Polar Axes Objects

Plot a line representing 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);

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
ax = 
  PolarAxes with properties:

             ThetaLim: [0 180]
                 RLim: [0 4]
       ThetaAxisUnits: 'degrees'
             ThetaDir: 'counterclockwise'
    ThetaZeroLocation: 'right'

  Show all properties

Access Individual Polar Axes Properites

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
rLimits = 

     0     4

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.

theta = 0:0.2:4*pi; 
rho = cos(2*pi*theta) + rand(size(theta));

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.

                       ALim: [0 1]
                   ALimMode: 'auto'
     ActivePositionProperty: 'outerposition'
               BeingDeleted: 'off'
                        Box: 'on'
                 BusyAction: 'queue'
              ButtonDownFcn: ''
                       CLim: [0 1]
                   CLimMode: 'auto'
                   Children: [1×1 Line]
                   Clipping: 'on'
                      Color: [1 1 1]
                 ColorOrder: [7×3 double]
            ColorOrderIndex: 2
                  CreateFcn: ''
                  DeleteFcn: ''
                  FontAngle: 'normal'
                   FontName: 'Helvetica'
                   FontSize: 10
              FontSmoothing: 'on'
                  FontUnits: 'points'
                 FontWeight: 'bold'
                  GridAlpha: 0.1500
              GridAlphaMode: 'auto'
                  GridColor: [0.1500 0.1500 0.1500]
              GridColorMode: 'auto'
              GridLineStyle: '-'
           HandleVisibility: 'on'
                    HitTest: 'on'
              Interruptible: 'on'
                      Layer: 'bottom'
                     Legend: [0×0 GraphicsPlaceholder]
             LineStyleOrder: '-'
        LineStyleOrderIndex: 1
                  LineWidth: 0.5000
             MinorGridAlpha: 0.2500
         MinorGridAlphaMode: 'auto'
             MinorGridColor: [0.1000 0.1000 0.1000]
         MinorGridColorMode: 'auto'
         MinorGridLineStyle: ':'
                   NextPlot: 'replace'
              OuterPosition: [0 0 1 1]
                     Parent: [1×1 Figure]
              PickableParts: 'visible'
                   Position: [0.1300 0.1100 0.7750 0.8150]
                      RAxis: [1×1 NumericRuler]
              RAxisLocation: 10
          RAxisLocationMode: 'auto'
                     RColor: [0.1500 0.1500 0.1500]
                 RColorMode: 'auto'
                       RDir: 'normal'
                      RGrid: 'on'
                       RLim: [0 2]
                   RLimMode: 'auto'
                 RMinorGrid: 'off'
                 RMinorTick: 'off'
                      RTick: [0 0.5000 1 1.5000 2]
                 RTickLabel: ''
             RTickLabelMode: 'manual'
         RTickLabelRotation: 0
                  RTickMode: 'auto'
                   Selected: 'off'
         SelectionHighlight: 'on'
                 SortMethod: 'childorder'
                        Tag: ''
                  ThetaAxis: [1×1 NumericRuler]
             ThetaAxisUnits: 'degrees'
                 ThetaColor: [0.1500 0.1500 0.1500]
             ThetaColorMode: 'auto'
                   ThetaDir: 'clockwise'
                  ThetaGrid: 'on'
                   ThetaLim: [0 360]
               ThetaLimMode: 'auto'
             ThetaMinorGrid: 'off'
             ThetaMinorTick: 'off'
                  ThetaTick: [0 45 90 135 180 225 270 315 360]
             ThetaTickLabel: {8×1 cell}
         ThetaTickLabelMode: 'manual'
              ThetaTickMode: 'manual'
          ThetaZeroLocation: 'top'
                    TickDir: 'in'
                TickDirMode: 'auto'
       TickLabelInterpreter: 'tex'
                 TickLength: [0 0]
                 TightInset: [0 0.0409 0 0.0409]
                      Title: [1×1 Text]
    TitleFontSizeMultiplier: 1.1000
            TitleFontWeight: 'bold'
                       Type: 'polaraxes'
              UIContextMenu: [0×0 GraphicsPlaceholder]
                      Units: 'normalized'
                   UserData: []
                    Visible: 'on'

Was this topic helpful?