image thumbnail

3D Polar Plot

version (431 KB) by Ken Garrard
Plots 3d polar data with polar axis and polar grid


Updated 04 Mar 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Polarplot3d produces surface, mesh, wireframe and contour plots for three dimensional polar data. A labeled polar axis is drawn at a fixed height or it can follow the surface contour at maximum radius. A polar grid can also be drawn on top of the surface.
This function is based on polar3d by J De Freitas, file exchange ID 7656.
The input parameters are a matrix of magnitudes, Zp, and a list of property,value pairs that modify the default plot behavior. Each column of Zp contains information along a single half-meridian and each row gives height values along a circular arc. By default Zp is assumed to be increasing in radius down each column and increasing in angle (counter-clockwise) along each row. The default plot is drawn over a full circle of unit radius.
'RadialRange' and 'AngularRange' properties can be used to specify the upper and lower angular and radial values over which the data is plotted. The relative ordering of the angular and radial range vectors is used to determine the angular and radial direction sense of the rows and columns of Zp. Alternatively a vector can be specified giving the locations of each row or column.

The polar axis can be placed at the minimum, maximum or mean value of Zp at the largest radius, at the top or bottom of the plot box, at a user specified location, or it can follow the surface at the perimeter of the data. The polar axis tick mark spacing can be adjusted with the 'TickSpacing' property.

The default polar axis orientation is that zero degrees is along the +X axis and increasing angles are counter-clockwise. The 'PolarDirection' property can be used to change this to a compass style plot with zero degrees along the +Y axis and increasing angles going clockwise around the pole.

Default surface coloring is according to the values in Zp. This can be changed by supplying a matrix the same size as Zp as the value of the 'ColorData' property.

A scaling parameter can be specified to interpolate the data onto a finer or coarser mesh. The output Cartesian data is returned in three matrices.

The example plot in the screenshot was produced with the following commands.

[t,r] = meshgrid(linspace(0,2*pi,361),linspace(-4,4,101));
[x,y] = pol2cart(t,r);
P = peaks(x,y); % peaks function on a polar grid

% draw 3d polar plot
figure('Color','white','NumberTitle','off','Name','PolarPlot3d v4.3');
polarplot3d(P,'PlotType','surfn','PolarGrid',{4 24},'TickSpacing',8,...
'AngularRange',[30 270]*pi/180,'RadialRange',[.8 4],...
'RadLabels',3,'RadLabelLocation',{180 'max'},'RadLabelColor','red');

% set plot attributes
set(gca,'DataAspectRatio',[1 1 10],'View',[-12,38],...
'Xlim',[-4.5 4.5],'Xtick',[-4 -2 0 2 4],...
'Ylim',[-4.5 4.5],'Ytick',[-4 -2 0 2 4]);
title('polarplot3d example');

The zip file contains the polarplot3d function and an m-file with example plots.

Cite As

Ken Garrard (2021). 3D Polar Plot (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!