New empty figure window shows up every time I run this colormap command

34 ビュー (過去 30 日間)
Leon
Leon 2025 年 8 月 26 日 17:30
編集済み: Stephen23 2025 年 8 月 26 日 19:10
I have a program created using App-Designer.
After adding the code below to my script, it would generate a new empty figure, every time I run the program.
colormap(app.Plot15, redwhiteblue(-40, 40));
https://www.mathworks.com/matlabcentral/fileexchange/86932-red-white-blue-colormap
What did I do wrong?

採用された回答

Stephen23
Stephen23 2025 年 8 月 26 日 17:45
編集済み: Stephen23 2025 年 8 月 26 日 18:03

"What did I do wrong?"

The documentation you referenced clearly states it's behavior with two input arguments: "REDWHITEBLUE(VMIN,VMAX), by itself, is the same length as the current figure's colormap. If no figure exists, MATLAB creates one."

If you are using a UIFIGURE (with it's default hidden handle) OR there is no figure open then I would expect a new figure to open, just as it's documentation explains.

we can also see in the code that with two arguments GCF is called: what do you expect to happen when GCF is called?

  2 件のコメント
Leon
Leon 2025 年 8 月 26 日 18:20
Many thanks for the tips.
In that case, how do I specify different colormaps for different plots then? I have many separate plots in my program.
Stephen23
Stephen23 2025 年 8 月 26 日 19:09
編集済み: Stephen23 2025 年 8 月 26 日 19:10
"how do I specify different colormaps for different plots then?"
Provide REDWHITEBLUE's third input argument.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRed についてさらに検索

製品


リリース

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by