1

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)

rose plot

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
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Lisa
  • 13
  • 4

2 Answers2

0

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;
Stewie Griffin
  • 14,889
  • 11
  • 39
  • 70
  • Thank you! -Defining alpha at the bottom of the script works perfectly. -But I have problems with the polaraxes. If I use your command lines, the values are plotted twice, once small and once in font size 25 and the data is not plotted anymore. Depending on where I paste your lines in my script, I additionally get the following errors: Error using newplot (line 76) Adding Cartesian plot to polar axes is not supported. Error in polar (line 74) cax = newplot(cax); Error in rose2 (line 84) h = polar(t,r); Error in RosePlot_PAC (line 157) rose2(inp, theta_rad) – Lisa Jan 11 '23 at 12:55
  • I wish I could help you more, but I can't :( I don't have Matlab anymore so I can't test your code. – Stewie Griffin Jan 11 '23 at 14:17
  • Most people have access to MATLAB here: https://matlab.mathworks.com/ – iohans Jan 13 '23 at 15:34
0

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.

Solstad
  • 285
  • 1
  • 9