Centering Colorbar and Reducing Label Padding
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John Cruce
el 31 de Jul. de 2023
Comentada: Star Strider
el 5 de Ag. de 2023
I have a colorbar that I've adjusted to be roughly 80% of its original size. I'd like to center the colorbar at the bottom inside of the figure. Below is a snippet of my code. How would I go about centering the reduced size figure on the figure axes?
hcb=colorbar('south');
hcb.Label.String='Colorbar Title';
colorbarpos=hcb.Position;
colorbarpos(2)=-0.015+colorbarpos(2);
colorbarpos(4)=0.4*colorbarpos(4);
colorbarpos(3)=0.8*colorbarpos(3);
hcb.Position = colorbarpos;
Additionally, I'd like to reduce the padding (line space) between the colorbar ticklabels and colorbar title (both above the colorbar). In other words, I'd like both to be closer to the colorbar as to not take up as much of the plot space. Any tips on how to best do this?
0 comentarios
Respuesta aceptada
Star Strider
el 1 de Ag. de 2023
Changing the position can be a bit more efficient —
hcb=colorbar('south');
hcb.Label.String='Colorbar Title';
colorbarpos=hcb.Position;
hcb.Position = colorbarpos+[0 0.015 0.8 0.4].*colorbarpos;
I am not certain what you are referring to with respect to the colorbar tick labels and the colorbar title. It would help to have at least a relevant example of some working code, or perhaps an image.
.
8 comentarios
Star Strider
el 5 de Ag. de 2023
My only suggestion at this point is to contact those who support the ‘m_map’ package to see what insights they may be able to offer with respect to the colorbar.
There is a section on colorbars and contour maps, and apparently a function called ‘m_contfbar’, although I have no experience with it and so cannot determine how to modify it, if any modifications are even possible. While I generally don’t suggest tweaking function code in situations such as this, creating your own version of ‘m_contfbar’ (giving it a slightly different name) that does what you want could work. I’ve not looked at any of this package, so I don’t know what language it’s written in, and if the code is compiled (that would be next to impossible to change) or exists as source code (that might be possible to change, given reasonable fluency in that specific language).
Anyway, taking a look at the ‘m_contfbar’ code would likely be the best place to begin. (I have no pressing need to download this package, however I’ll certainly keep it in mind in case I need to do any mapping projects.)
.
Más respuestas (0)
Ver también
Categorías
Más información sobre Axis Labels en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!