How to insert tick and numbers for spherical axes?

1 view (last 30 days)
I've managed to plot my data using patternCustom() function :
I want to add ticks and numbers to the elevation and azimuth polar axes - is that possible?
Thanks.

Answers (1)

AR
AR on 24 Mar 2025
I understand that you want to add ticks and numbers to the elevation and azimuth in polar axes. The “patternCustom” function generates a 3D Cartesian plot (axes) and to display ticks and labels, manually set them on the Cartesian axes (X and Z axes) to indicate azimuth and elevation, respectively.
Below is an example code for the same:
% Example Data
azimuth = -180:10:180; % Azimuth angles in degrees
elevation = -90:10:90; % Elevation angles in degrees
[Az, El] = meshgrid(azimuth, elevation);
magnitude = abs(cosd(Az)) .* abs(cosd(El));
% Reshape Data for patternCustom
Az = Az(:);
El = El(:);
magnitude = magnitude(:);
% Plot Using patternCustom()
figure;
patternCustom(magnitude, Az, El);
% Access Current Axes
ax = gca;
ax.Visible = 'on'; % Ensure Axes are visible
Setting Azimuth (θ) ticks and labels on the X-axis using "xticks()" and "xticklabels()".
% Set Azimuth (θ) Ticks and Labels (X-Axis)
xticks(-180:45:180); % Set tick positions
xticklabels(string(-180:45:180)); % Set tick labels
Setting Elevation (φ) ticks and labels on the Z-axis using "zticks()" and "zticklabels()".
% Set Elevation (φ) Ticks and Labels (Z-Axis)
zticks(-90:30:90); % Set tick positions
zticklabels(string(-90:30:90)); % Set tick labels
Adjusting the viewing angle using "view()" to make the data more interpretable.
% Set Axis Labels
xlabel('Azimuth (°)');
ylabel('Magnitude');
zlabel('Elevation (°)');
view(135, 30);
grid on; % Show grid for clarity
% Ensure the plot is refreshed
drawnow;
This approach provides a visual representation of azimuth and elevation angles like what you might expect from a polar plot. If true polar plotting is required, consider using MATLAB's polar plotting functions, such as polarplot or polaraxes, which are specifically designed for polar coordinates.
Refer the below links for more information:
Hope this is helpful!

Community Treasure Hunt

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

Start Hunting!