How can I move the colorbar in a surf plot?
34 次查看(过去 30 天)
显示 更早的评论
When using the following code, the colorbar overlaps with the tick labels of the x-axis:
surf(peaks);
set(gca,'FontSize',28);
cb = colorbar;
I already tried to modify the x-position of the colorbar with:
pos = get(cb,'Position');
set(cb,'Position',pos + [0.05,0,0,0]);
This was unsuccessful since the whole axis is rescaled and even manually entering the retrieved original position values does not result in the original colorbar position. How can I move the colorbar to not overlap with the tick labels anymore?
Edit: The provided sample code is a simplified example and the increased fontsize is necessary for readability in my original code. My attempt to solve the problem was aimed at moving the colorbar further to the east.
1 个评论
采纳的回答
更多回答(1 个)
KALYAN ACHARJYA
2018-9-14
编辑:KALYAN ACHARJYA
2018-9-14
surf(peaks);
set(gca,'FontSize',8);
cb=colorbar;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195711/image.png)
3 个评论
KALYAN ACHARJYA
2018-9-14
编辑:KALYAN ACHARJYA
2018-9-14
If you want at a specific location, mention it in the comment section.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colorbar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!