ankit agrawal
ankit agrawal

Reputation: 311

How to set theta limit in -90 to 90 range in MATLAB?

How to set theta range from 0 to 90 and 270 to 360 in a single plot.

thetalim([theta_lower,theta_upper])

enter image description here

Upvotes: 2

Views: 453

Answers (1)

Sardar Usama
Sardar Usama

Reputation: 19689

To set it from -90° to 90°, just set it from -90° to 90° i.e.

%Creating a random polar plot with same ThetaDir and ThetaZeroLocation as yours
theta = linspace(0, 2*pi);
rho = rand(1, 100);
polarplot(theta, rho);
ax = gca;
set(ax,'ThetaDir', 'clockwise', 'ThetaZeroLocation', 'top');

%Setting the desired limits
thetalim([-90 90]);

and if you want to have positive values for theta then you can change the ticklabels as follows:

ax.ThetaTickLabel = wrapTo360(ax.ThetaTick); %requires Mapping Toolbox
% or without Mapping Toolbox:
% ax.ThetaTickLabel(ax.ThetaTick<0) = split(num2str(ax.ThetaTick(ax.ThetaTick<0) + 360));

Upvotes: 2

Related Questions