- The first two expected inputs are the same as histcounts2() which are arrays of raw data. The inputs you shared look like the bins and counts. So you'll need to produce the correct inputs which isn't a big deal.
- The final plot isn't really a polar plot. It's a cartesian plot that mimicks a polar plot similar to Matlab's outdated polar() function. This isn't a big problem unless you expect to alter the polar properties after plotting.
How to plot something like this?
2 views (last 30 days)
Show older comments
Hello everyone,
Assume that I have this 3 datasets (A, B, C) and I want to have a plot like this (please kindly ignore the white space in the southwest of it because I want a full polar plot)
So I tried to make it using this script:
clear; clf; close; clc;
A = [19,6,13,4,20,12,5,17,3,8,16,9,1,10,2,18,15];
B = [11,13,12,8,19,14,18,20,7,1,6,15,4,10,17,16,3];
C = [2,7,11,17,3,16,14,5,19,10,12,20,1,4,6,13,8];
figure
ax = polaraxes();
polarhistogram(A,18,'FaceColor','b')
hold on
polarhistogram(B,18,'FaceColor','r')
hold on
polarhistogram(C,18,'FaceColor','g')
theta = linspace(0,2*pi,18); % 17 equally spaced angles (18 points)
ax.ThetaDir = 'clockwise'; %make january first
ax.ThetaZeroLocation = 'top'; %make january first
monthNames = {'Jan.' 'Feb.' 'Mar.' 'Apr.' 'May' 'Jun.' 'Jul.' 'Aug.' 'Sep.'...
'Oct.' 'Nov.' 'Dec.' 'Winter' 'Spring' 'Summer' 'Autumn' 'Annual'};
set(ax, 'ThetaAxisUnits', 'radians', 'ThetaTick', theta(1:end-1),...
'ThetaTickLabel', monthNames);
Also, I can see the amount that presented in the r-axis not present the amount of my data; for instance, in Annual (17th in C) the value of C In my data is 8 but in the figure, it seems to is 2. So I want to ask you please guide me on how to have a plot like this?
Also, the amount of January does not show directly in front of it, but it shows between January and February and I don't know how to fix it.
An extra description is the value of each data set A, B, and C represents the data for January to December and Winter, Spring, Summer, Autumn, and Also annual value (12 months + 4 seasons + 1 annual = 17).
In case if they are overlapped it's no matter what color showing in the plot just one of them is good.
Thank you so much...
2 Comments
Adam Danz
on 30 Jul 2020
Edited: Adam Danz
on 30 Jul 2020
The visualization is a bivariate histogram in polar coordinates and Matlab does not currently offer such a function.
I found this function on the exchange that does what you're asking, with 2 caveats. histogram2Polar()
Since patch objects are not supported with polar axes, and since histogram2(), imagesc() and friends are not supported by polar axes either, I don't see an alternative approach.
Answers (0)
See Also
Categories
Find more on Polar Plots 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!