Customise colorbar labels (exponent)
54 次查看(过去 30 天)
显示 更早的评论
Hello everyone, I have a problem with setting up a colorbar for a coloured contour plot. For matter of coherence with overlying contour lines, I would like the labels of the ticks of the colorbar expressed as 5, 10 and 15 * 10^10 and not 0.5, 1 and 1.5 *10^11. In other words, I would like "x 10^10" above the numbers of the ticks in place of "x 10^11" as now appears (see image) (and not other solutions like "e10" after each single tick label).
Now my code is just
c = colorbar;
c.Ticks=[-15*10^10:5*10^10:15*10^10];
Thank you to whoever will be able to answer my question.
0 个评论
采纳的回答
dpb
2022-9-21
编辑:dpb
2022-9-21
@Star Strider is on the right track; the colorbar numeric ruler handle is hidden, however, but it is there and writeable --
For your example above, use
c=colorbar;
c.Ruler.Exponent=10; % set the desired exponent
c.Ruler.TickLabelFormat='%0.1f'; % fix up ugly default %g formatting
To illustrate with an example modified from the doc, first use a default colorbar forcing a big exponent
surf(peaks/1E11)
hCB=colorbar;
Then, fixup the exponent as desired to see the difference...
surf(peaks/1E11)
c=colorbar;
c.Ruler.Exponent=-10; % set the desired exponent
c.Ruler.TickLabelFormat='%0.1f'; % fix up ugly default %g formatting
Search for Yair Altman's FEX submittal to retrieve undocumented/hidden object handles.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!