- polarplot: https://www.mathworks.com/help/matlab/ref/polarplot.html
- text: https://www.mathworks.com/help/matlab/ref/text.html
For a semi circle polar plot, how to add the radius labels on both sides of the plot?
14 views (last 30 days)
Show older comments
This almost makes the plot I want. I just would like the radial circles labeled 10, 20, 30, and 40 on the left side of the plot. Also, why is the angle, th, in radians instead of degrees? Also, how to "label" the x axis. Something like "Football Player Running Speed, m/s". This would be centered, horizontal, below the number 0.
% Test points are at radius 10, 20, 30, and 40 and azimuth -90:15:90
% Generate test points
th = -90:15:90;
r = [ th*0+10 th*0+20 th*0+30 th*0+40 ];
th = [ th th th th]*pi/180; % <- WHY CONVERT TO RADIANS, BUT PLOT IS IN DEGREES?
% Plot the points
h_plt = polarplot(th,r, 'o');
% Change to clockwise, and with theta zero at the top
h_ax = gca;
h_ax.ThetaDir = 'clockwise';
h_ax.ThetaZeroLocation = 'top';
% Plot only the upper half
h_ax.ThetaLim = [-90 90];
% Add degree symbols to theta tick labels
for it = 1:length(h_ax.ThetaTickLabel)
h_ax.ThetaTickLabel{it}=[h_ax.ThetaTickLabel{it}, '^{\circ}'];
end
0 Comments
Answers (1)
Poorna
on 15 Sep 2023
Hi John,
I understand that you want to plot the radial labels on the left side of the plot as well. Also, you want to put a label along the x-axis of the plot.
First, coming to your question on why converting the "theta" points to radians. According to the documentation of the "polarplot" function, the input to the "theta" values must be in radians.
Second, it is not possible to have multiple "rticks" for a single plot in MATLAB. However, you can use the "text" function to achieve the required figure. You can put multiple texts across the left side of the plot with "r" values and place them appropriately using the coordinates. By following above mentioned steps, you can get a similar figure as if there are two "rticks".
You can use the same "text" function to put the label below the plot across the "x-axis".
Kindly refer to the following links to know more about the functions used above:
Hope this helps!
0 Comments
See Also
Categories
Find more on Annotations 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!