Clear Filters
Clear Filters

adding axis to polar plot

4 views (last 30 days)
Benjamin Cowen
Benjamin Cowen on 9 Aug 2017
Answered: Faiz Gouri on 16 Aug 2017
I have a polar plot that has colored contours. I cannot figure out how to add my axis. The code is below:
close all
data1 = xlsread('C:\Users\Desktop\practice.xlsx','theta');
data2 = xlsread('C:\Users\Desktop\practice.xlsx','r');
data3 = xlsread('C:\Users\Desktop\practice.xlsx'','z');
t = data1(1,:);
r = data2(:,1);
z = data3(:,:);
myColorMap = colormap;
myColorMap(1,:) = [1 1 1];
caxis([0 25]);
beta = 0.9;
From here I cannot figure out how to plot my axes. For instance at theta=0, I would like [100], etc. Whenever I try what usually works,
thetaticks([0 15 30 45 60 75 90 105 120 135 150 165 180 195 210 225 240 255 270 285 300 315 330 345])
rticks([100 200 300])
rticklabels({'100 eV','200 eV','300 eV'})
ax = gca;
ax.ThetaAxis.TickLabelInterpreter = 'latex';
ax.ThetaTickLabel = {'[100]','','','[101]','','','[001]','','','[$\overline{1}$01]','','','[$\overline{1}$00]','','','[$\overline{1}$0$\overline{1}$]','','','[00$\overline{1}$]','','','[10$\overline{1}$]','','','[$\overline{1}$0$\overline{1}$]'};
I just get riddled with errors involving trying to use polar axes on a cartesian chart. I can plot circles below which can give me the different r mag, but seems kind of a silly way to do it to me: (below)
axis equal
axis off
I want to add labels to these circles. First circle is 100 eV, second is 200 eV, etc.
But I also want axis labels around the circle corresponding to direction. Can I automate this with MATLAB or do I just need to do it manually?

Answers (1)

Faiz Gouri
Faiz Gouri on 16 Aug 2017

If you are using R2016a or later, use the polarplot function. It gives you the option of specifying the 'RTickLabel' and 'ThetaTickLabel' values. You will need to use sprintf and strsplit to create the labels and a cell array to use as the radius.

eV = linspace(0, 10, 5);
eVstr = sprintf('%.1f eV\n', eV);
eVlbl = strsplit(eVstr, '\n');
eVlbl = eVlbl(1:end-1);

For older version the following article might be useful-


Find more on Polar Plots in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!