How to enable the colorbar to only show the vertical scale with values ?

3 views (last 30 days)
I am using a colorbar command to have a vertical scale besides my polarplot. When its position property is used it is working fine, but i want it to appear as the same size of the polarplot. I have used the location propert to make it appear so. But now the problem is it was showing colormap with colors. I have attached the pictures and link to my previous answered question. All this mess occurs because i want my legend to be displayed under the plot so i have used outside position argument of legend.
Mahesh Babu Dhanekula
Mahesh Babu Dhanekula on 13 Aug 2020
Dear jonas, i don't know about how to create separate axis. Please see the code in comments.

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 13 Aug 2020
Edited: Adam Danz on 14 Aug 2020
The plot below was produced using your exact code as it appears in the comment under the question plus the following two lines at the end,
hBar.Position(3) = 0.00001; % Make it narrow
hBar.Position(1) = 0.15; % move it leftward
Is this what you're looking for?
Using r2020a Update 5.
  1 Comment
Adam Danz
Adam Danz on 13 Aug 2020
BTW, I have no idea how to interpret that scale.
Why are there two 0s and 10s?
Why does it go from -10 to 0 at the bottom?
What do those values even mean? -- you could use ylabel(hBar, 'Label')

Sign in to comment.

More Answers (1)

jonas on 13 Aug 2020
Edited: jonas on 13 Aug 2020
Not sure if this answers your question, but it's an alternative to using a colorbar for scale. Also did not use the "outside" argument of legend as you mentioned it being problematic.
% create the plots
hold off
ax(1) = gca;
hold on
%add legend and change position
hLegend = legend('a','b','orientation','vertical','location','south');
hLegend.Position(1:2) = [0.8 0.8]
%make new axis and align with first one
ax(2) = axes('color','none');
ax(2).XAxis.Visible = 'off';
ax(2).Position([2,4]) = ax(1).Position([2,4]);


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!