Centering Colorbar and Reducing Label Padding
22 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2023-8-1
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 个评论
Star Strider
2023-8-5
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.)
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!