I have a polar plot. Is there a way to label the axes?
Show older comments
For the r axis, I would like to label "Energy (eV)" How do I do that?
1 Comment
Walter Roberson
on 9 Jan 2017
Edited: Walter Roberson
on 9 Jan 2017
Oddly, the new polarplot() that creates Polar Axes objects, has no provision for axes labels.
I just now put in an enhancement request for this.
Accepted Answer
More Answers (2)
Walter Roberson
on 9 Jan 2017
0 votes
polar() is pretty much plot() of pol2cart() behind the scenes. There is no support for r or theta labels. There is the xlabel and ylabel from the underlying axes, but that is not very useful.
So, what you have to do is pick out an axes position in r and theta terms, pol2cart those into x y components, and text() at that position.
Star Strider
on 9 Jan 2017
If you have R2016a or later, use the polarplot function. It gives you the option of specifying the 'RTickLabel' (link) values. That is likely as close as you can get to what you want to do.
You will need to use sprintf and strsplit to create the labels and a cell array to use as the radius labels.
Example:
eV = linspace(0, 10, 5);
eVstr = sprintf('%.1f eV\n', eV);
eVlbl = strsplit(eVstr, '\n');
eVlbl = eVlbl(1:end-1);
The last element of the original ‘eVlbl’ is an empty string that can cause problems with vector length matching, so it is necessary to eliminate it by the second ‘eVlbl’ assignment.
Experiment with it. If you have problems, describe them here. We can help.
7 Comments
Benjamin Cowen
on 11 Jan 2017
Star Strider
on 11 Jan 2017
Apparently there is, since Steven Lord says so. It’s just not in the documentation, so I didn’t know it existed. The 'RTickLabel' option is as close as I could come. It labels the radius ticks, using the sort of cell array I created in ‘eVlbl’.
I’ll delete my Answer in a few hours, since it’s obviously not contributing anything substantive.
Benjamin Cowen
on 11 Jan 2017
Star Strider
on 11 Jan 2017
Is that enough to reproduce your plot? Do you need to attach your data also? What version of MATLAB are your running?
Benjamin Cowen
on 11 Jan 2017
Star Strider
on 11 Jan 2017
I was specifically suggesting the arguments to your polarplot calls. Do we need those to understand your problem, or will any vectors do for ‘a’, ‘f’ and the rest?
Walter Roberson
on 12 Jan 2017
The example Steven http://www.mathworks.com/matlabcentral/answers/319725-i-have-a-polar-plot-is-there-a-way-to-label-the-axes#comment_419725 gave works for me. I would not say that the location or direction it chooses is exactly my first choice. You might want to set the ruler Rotation to 0 or change the font size or something like that.
Categories
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!