Adding gridlines to polarcontour plot

1 view (last 30 days)
Benjamin Cowen
Benjamin Cowen on 28 Oct 2017
Edited: Benjamin Cowen on 28 Oct 2017
I attached 2 images. One shows the ideal grid lines and labels on a polar plot. With the other figure, I am unsure how to add this stuff. I did a make-shift add of concentric circles to generate the radial gridlines but I am still missing other gridlines. Any help in getting the "needs_work" image to look the "ideal" image? Just in terms of grid lines and labels, not the actual content on the graph.
For instance, why does:
x = linspace(0,1,400);
y = x;
not add a line to my graph?
data1 = xlsread('C:\Users\Ben\data.xlsx','theta');
data2 = xlsread('C:\Users\Ben\data.xlsx','r');
data3 = xlsread('C:\Users\Ben\data.xlsx','C_Vac angles');
t1 = data1(1,:);
r1 = data2(:,1);
z1 = data3(:,:);
title('Carbon PKA C FP')
[C,h] = polarcont(r1,t1,z1,250);
colormap jet
axis equal
axis off
% caxis([0 7])
I use this function:
% POLARCONT Polar contourf plot
% Richard Rieber
% April 4, 2007
% Updated June 15, 2007
% function [C,h] = polarcont(r,theta,z,N,s)
% Purpose: This function creates polar contourf plots on the current active
% figure
% Inputs: o r - Radius vector of length m
% o theta - Angle vector in radians of length n
% o z - Magnitude at the points specified in r and theta of
% size m x n
% o N - The number of contourfs to plot [OPTIONAL]
% o s - Linespec as described in PLOT [OPTIONAL]
% Outputs: o C - returns contourf matrix C as described in contourfC
% o h - Column vector H of handles to LINE or PATCH objects,
% one handle per line.
% - Both C and h can be used as inputs to CLABEL
% - Colors are defined in colormap
% - Treat this function as a standard contourf plot
function [C,h] = polarcont(r,theta,z,N,s)
[a,b] = size(z);
if a ~= length(r)
error('r is not the same length as the first dimension of z')
if b ~= length(theta)
error('theta is not the same length as the second dimension of z')
x = zeros(a,b);
y = zeros(a,b);
for j = 1:a
for k = 1:b
x(j,k) = r(j)*cos(theta(k));
y(j,k) = r(j)*sin(theta(k));
if nargin == 3
[C,h] = contourf(x,y,z);
elseif nargin == 4
[C,h] = contourf(x,y,z,N);
elseif nargin == 5
[C,h] = contourf(x,y,z,N,s);
error('Incorrect number of inputs')

Answers (0)

Community Treasure Hunt

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

Start Hunting!