# Adding gridlines to polarcontour plot

1 view (last 30 days)
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;
plot(x,y)
not add a line to my graph?
t1 = data1(1,:);
r1 = data2(:,1);
z1 = data3(:,:);
figure(1)
title('Carbon PKA C FP')
[C,h] = polarcont(r1,t1,z1,250);
set(h,'LineColor','none')
colormap jet
colormap(flipud(jet))
colorbar
plotting_circle(0,0,100);
plotting_circle(0,0,200);
plotting_circle(0,0,300);
plotting_circle(0,0,400);
axis equal
axis off
% caxis([0 7])
I use this function:
% POLARCONT Polar contourf plot
%
% Richard Rieber
% rrieber@gmail.com
% 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.
%
% OTHER NOTES:
% - 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')
end
if b ~= length(theta)
error('theta is not the same length as the second dimension of z')
end
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));
end
end
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);
else
error('Incorrect number of inputs')
end