How to change the axis limits and remove/alter the ticks and labels for a COMPASS/POLAR plot?
Afficher commentaires plus anciens
I would like to change the axes properties of a compass plot within the code without using the manual plotting edit tool.
For instance, I would like to:
1) Set the magnitude of the axis to a certain maximum number no matter what the data is that I am plotting.
2) Change the rotational axis labels.
Réponse acceptée
Plus de réponses (2)
Adam Danz
le 30 Mar 2014
Modifié(e) : MathWorks Support Team
le 17 Fév 2021
Hello all, I had a similar issue using polar plots so I wrote a code that does the trick. https://www.mathworks.com/matlabcentral/fileexchange/46087-polarticks-m
After creating your polar plot, you can run this code to adjust the circumference intervals and tickmarks. For example,
p = polar (deg2rad([25, 25]), [0, 33])
h = polarticks(8, p)
This will remove all radii and ticks and replace them with 8 equally spaced intervals (ie, 45 deg). See description within code for more details.
Adam
Starting in R2024b, the compassplot function can be used in place of compass to create arrows eminating from the origin of a polar axes. The PolarAxes class has many properties and several functions you can use to customize its appearance. Note that compassplot can be combined in a PolarAxes with other plots like polarhistogram, polarplot, polarscatter, etc.
t = linspace(pi/3,2*pi,10);
cp = compassplot(t,sin(t)) % new in R2024b
pax = gca % get a handle to the PolarAxes
% Set the radial axis limits.
pax.RLim = [ 0 2 ];
% Customize the tick values and tick labels.
thetaticks( [0 90 180 270]);
thetaticklabels(["East","North","West","South"])
Catégories
En savoir plus sur Polar Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
