Creation of a colorbar with quantized solid block-like colors and 180º rotation of the colobar label

11 views (last 30 days)
Richard Wood
Richard Wood on 1 Jun 2020
Answered: darova on 16 Jun 2020
Hello everyone,
I am dealing with the following type of figure
ylabel(clr1,'Relative angle, $\phi \, \, \left( \mathrm{rad} \right)$','Interpreter','Latex','FontSize',14);
xlim([0 60]);
ylim([0 20]);
caxis([0 3*pi/2]);
This results in a figure of the type of the attached file called "1". Referring to this figure and code, I would like to make some changes. The first of these, the matrix called "matrix" in my code is a matrix made up of only the following values: 0, pi/2, pi, and 3*pi/2. This being the case, the ideal would be to create a colorbar which would be made up of only four solid blocks, with no color gradient between them, representing the aforementioned values. Also, it would be great if there was some way to center the label "0", "pi/2", "pi", and "3pi/2" in the middle of their corresponding blocks. I would also like to see if it would be possible to eliminate, in that case, the small ticks that mark the appearance of the aforementioned labels currently in the colorbar. Finally, I was wondering if it is possible to rotate the colorbar label "Relative angle..." 180º degrees, as it can be seen in the attached file called "2", keeping its position centered with respect to the total length of the colorbar.
Thank you for your attention.

Accepted Answer

darova on 16 Jun 2020
This should be helpfull
h = colorbar('location','north');
txt = {'0' 'pi/2' 'pi' '3*pi/2'};
for i = 1:4
h1 = annotation('textbox', [0.175*i+0.05 0.81 1 0.1], ...
'string', txt{i}, ...
cm = jet(4);

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!