How to change the colorbar limits in a previously saved fig file

6 次查看(过去 30 天)
Hello,
I have a figure containing a colorbar that I saved in a .fig format.
Now I need to open it and change the limits of the color bar. Im using
caxis([inferior_limit superior_limit])
.
However, when I do this nothing happens.
What Im doing wrong?
Thank you

采纳的回答

Walter Roberson
Walter Roberson 2021-10-11
figfilename = 'AppropriateFile.fig';
fig = openfig(figfilename);
cb = findobj(fig, 'type', 'Colorbar');
cb.Limits = [inferior_limit superior_limit];
After that you might want to save the figure indicates in fig into a new file.
  7 个评论
Walter Roberson
Walter Roberson 2021-10-13
imagesc() sets the image 'CDataMapping', 'scaled' . If a non-empty scale range is provided, then it also sets the axes CLim property to that range; if "hold" was off then it also sets the axes CLimMode to 'auto'
This is almost the same calling imagesc() without a range and then calling caxis() yourself; the difference is just in whether CLimMode is set to 'auto' or not (caxis does not set it.)
If you still have your figure up but you want to change the caxis and save again while it is still up, then referring to your previous code,
caxis(ax1, [inferior_limit superior_limit]);
savefig(SPLfigure, 'teste.fig')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by