adding axis to polar plot

5 ビュー (過去 30 日間)
Benjamin Cowen
Benjamin Cowen 2017 年 8 月 9 日
回答済み: Faiz Gouri 2017 年 8 月 16 日
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(:,:);
figure(1)
title('Displacement')
polarcont(r,t,z)
myColorMap = colormap;
myColorMap(1,:) = [1 1 1];
colormap(myColorMap);
colorbar;
caxis([0 25]);
beta = 0.9;
brighten(beta)
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)
plotting_circle(0,0,100);
plotting_circle(0,0,200)
plotting_circle(0,0,300)
plotting_circle(0,0,400)
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?

回答 (1 件)

Faiz Gouri
Faiz Gouri 2017 年 8 月 16 日

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- http://www.mathworks.com/matlabcentral/answers/319725-i-have-a-polar-plot-is-there-a-way-to-label-the-axes#comment_419725

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by