如何在 MATLAB 中设置自定义默认颜色图?
有人在其他地方问过这个问题并被告知是一个“提示”此处,但我对 MATLAB 还很陌生,不知道如何使用该提示。
我有一个文件 cmap.mat
。我加载它并更新颜色图,如下所示:
load cmap.mat;
colormap(cmap);
但它仅适用于当前图形。我希望所有的数字都使用这个颜色图。
Someone asked this question elsewhere and was told there was a 'hint' here, but I'm quite new to MATLAB and don't see how to use that hint.
I have a file cmap.mat
. I load it and update the colormap as follows:
load cmap.mat;
colormap(cmap);
But it only works for the current figure. I'd like all figures to use this colormap.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要设置所有图形都将使用的默认属性,您必须在根对象。 这里有一些更好的文档解释了如何做到这一点。在您的情况下,您将执行以下操作:
通常,您必须设置的属性名称将是单词
'Default'
后跟句柄对象名称(即'Figure'、
'Line'
、'Surface'
等),后跟您要设置默认值的属性名称。设置后,将创建后续句柄对象,并将该属性设置为您指定的默认值。注意:您设置的默认属性值仅适用于当前 MATLAB 会话。如果重新启动 MATLAB,默认值将恢复为出厂设置。要在每次启动 MATLAB 时使用相同的默认值,请在
'startup.m'< 中应用它们/代码> 文件
。
To set a default property that all figures will use, you have to set that default value on the root object. Here's some better documentation explaining how to do it. In your case, you would do the following:
In general, the property name you have to set will be the word
'Default'
followed by the handle object name (i.e.'Figure'
,'Line'
,'Surface'
, etc.) followed by the property name you are setting the default for. Once set, subsequent handle objects will be created with that property set to your specified default.Note: The default property values you set will only last for the current MATLAB session. If you restart MATLAB, the default values will revert to their factory settings. To use the same defaults every time you start MATLAB, apply them within your
'startup.m'
file.