I use the function rose2 in my script in order to plot a rose plot. I am working with Matlab 2016a and thus still use the rose function. I use rose2 in order to be able to set the maximum value for the r axis and fill the triangles. I use "findall" in order to rotate the location of the R-axis labels. This works very well:
maxHistogramValue = 100;
f=figure;
clf
% Set the max value to maxHistogramValue:
polar(0, maxHistogramValue,'-k')
% Set the location of the R-axis labels in degrees.
% Extract all of the 'Text' objects from the polar plot.
ax = findall(f.Children, 'Type', 'Axes');
% Filter the 'Text' objects by the 'HorizontalAlignment' property.
% PLEASE NOTE: This may not generalize to other versions of MATLAB
% where the default 'HorizontalAlignment' value for R-axis labels is not
% set to 'left'.
labels = findall(ax, 'Type', 'Text', 'HorizontalAlignment', 'left');
% Set the degrees of the R-axis Labels.
degrees = 285;
% Update the position of each R-axis label.
for label = labels'
currentX = label.Position(1);
currentY = label.Position(2);
radius = sqrt(currentX^2 currentY^2);
newX = cos(degtorad(degrees)) * radius;
newY = sin(degtorad(degrees)) * radius;
label.Position = [newX, newY];
end
hold on;
% Now use rose2:
rose2(inp, theta_rad)
%make transparent
alpha(0.5)
view(-90,90)
And I figured out how to change the font size with:
labels = findall(ax, 'Type', 'Text');
for label = labels'
label.FontSize = 16;
end
But I want to display the angles with the degree symbol. I tried to add it to the loop, but first, weired numbers are displayed and second, it also changes the r Axis, which I dont want of course.
labels = findall(ax, 'Type', 'Text');
for label = labels'
label.FontSize = 16;
label.String=label.String char(176);
end
Can anyone help please???
Thank you!
CodePudding user response:
Try alpha(0.5)
, either in the rose2
function or at the bottom of your script to get the transparency you want.
Also, try polaraxes
to define the font size.
ax = polaraxes;
ax.FontSize = 25;
CodePudding user response:
If you look at labels
you will see that it contains more labels. You only want to modify labels(1:12)
:
labels = findall(ax, 'Type', 'Text');
for label = labels(1:12)'
label.String=[label.String char(176)];
end
Also, your label.String=label.String char(176);
is not matlab syntax.