- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Polar Axes Appearance and Behavior in MATLAB
In data visualization, the polar axes are used to represent data in polar coordinates. Polar axes provide a way of visualizing complex data in the form of polar plots. Read this article to learn the methods of changing the properties of polar axes to control their appearance and behavior.
Before learning to customize the appearance and behavior of polar axes, let us see how to create a polar axes and polar plot in MATLAB.
How to Create Polar Axes in MATLAB?
In MATLAB, there is a built-in function named "polaraxes" used to create polar axes in MATLAB figures.
Its syntax is as follows −
polaraxes();
Example
The following example demonstrates that how to create the polar axes using the "polaraxes" function in MATLAB.
% MATLAB code to create default polar axes % Create a default polar axes polaraxes; % Sample data to create a polar plot theta = linspace(0, 2*pi, 150); value = sin(2*theta); % Plot data on the polar axes polarplot(theta, value); title('Default Polar Axes');
Output
It will produce the following output −
This example code shows how to create the polar axes with default properties in MATLAB.
Polar Axes Properties
The following are some important properties of polar axes that we can change in MATLAB.
Axes ticks
Axes limits
Axes tick labels
R-axis (radial-axis) tick angle
Let us discuss how to customize each of these properties of polar axes using MATLAB.
Add Axes Ticks to Polar Axes
In polar axes, the axes ticks are small marks used to represent the specific data values of the axes.
In the case of polar axes, we have two axes ticks namely, radial axis tick (y-axis tick) and angular axis tick (x-axis tick).
In MATLAB, we have two options namely, "ThetaTick" and "RTick" to add angular and radial axes ticks respectively, to the polar axes.
Example
Here is an example showing the way of adding axes ticks to the polar axes.
% MATLAB code to add customized axes ticks % Creating default polar axes ax = polaraxes; % Defining Sample data to create a polar plot theta = linspace(0, 2*pi, 100); value = sin(2*theta); % Creating a polar plot polarplot(ax, theta, value); title('Customized Polar Axes with Ticks'); % Adding axes ticks to polar axes ax.ThetaTick = [0:45:315]; ax.RTick = [0:0.2:1];
Output
It will produce the following output −
This example shows how to add customized polar axes ticks.
Customize Axes Limits of Polar Axes
In MATLAB, we can customize the limits of polar axes. For this, MATLAB provides two built-in functions namely, "thetalim" and "rlim" to customize the theta axis limit and radial axes limit respectively.
Its syntax is as follows −
thetalim(Vector of theta axis limits); rlim(Vector of r-axis limits);
Example
Take a look the following example to understand this task.
% MATLAB code to customize polar axes limits % Create a polar axis ax = polaraxes; % Create data for polar plot t = linspace(0, 2*pi, 100); r = sin(2*t); % Create a polar plot of the data polarplot(ax, t, r); % Customize the polar axis limits rlim([0, 2]); % Radial axis limit thetalim([0, 180]); % Theta axis limit
Output
It will produce the following output −
This example shows how to customize the axes limits of a polar plot.
Add Axes Tick Labels to Polar Axes
MATLAB also provides a way of adding customized axes tick labels to polar axes in a polar plot. For this, MATLAB has two built-in functions namely, "rticklabels" and "thetaticklabels" to customize radial axis tick label and theta axis tick label respectively.
h3>Its syntax is as follows −
rticklabels(Specify R-Tick Labels); thetaticklabels(Specify Theta-Tick Labels);
Example
Let us take an example to understand how to add customized axes tick labels to polar axes.
% MATLAB code to customize polar axes tick labels % Create a polar axis ax = polaraxes; % Create data for polar plot t = linspace(0, 2*pi, 100); r = sin(t); % Create a polar plot of the data polarplot(ax, t, r); % Customize polar axes ticks and labels rticks([0, 0.2, 0.4, 0.6, 0.8, 1.0]); % Radial axis ticks % Radial axis tick labels rticklabels({'a=0', 'b=0.2', 'c=0.4', 'd=0.6', 'e=0.8', 'f=1.0'}); thetaticks([0, 90, 180, 270]); % Theta axis ticks % Theta axis tick labels thetaticklabels({'Right', 'Top', 'Left', 'Bottom'});
Output
It will produce the following output −
This example shows the way of customizing the axes tick labels of a polar plot.
Change R-Tick Angle of Polar Axes
In MATLAB, we can change the angle of radial axis ticks. For this, MATLAB provides a function "rtickangle".
Its syntax is as follows −
rtickangle(axis, angle);
Example
The following example shows the method of changing r-tick angle of the polar axes.
% MATLAB code to change R-tick angle % Create a polar axis ax = polaraxes; % Create data for polar plot t = linspace(0, 2*pi, 100); r = sin(2*t); % Create a polar plot of the data polarplot(ax, t, r); % Change the R-tick angle rtickangle(ax, 270); % Rotating R-tick to 270°
Output
It will produce the following output −
This example demonstrates the method of changing the angle of R-ticks of a polar plot.
Conclusion
In conclusion, we can change various properties of polar axes to change their appearance and behavior according to our needs. We can add custom ticks and tick labels, rotate R-ticks, and more. In this article, I explained the methods of changing some important properties of polar axes with the help of examples in MATLAB.
To Continue Learning Please Login
Login with Google