フィルターのクリア

Exportgraphics does only export black images from UIAxes

13 ビュー (過去 30 日間)
Adrian
Adrian 2024 年 1 月 24 日
回答済み: Adrian 2024 年 1 月 25 日
Hello.
I've been working on an app and I want to export the content of some UIAxes. This results only in black images.
To explain further:
plot(gca, rand(1, 100))
exportgraphics(gca, 'kajsdfgh.png')
gives what expected, a random plot. But
fig = uiaxes;
plot(fig, rand(1, 100))
exportgraphics(fig, 'ydklfg.png')
only returns a black image.
I'm using R2023b and I've been using this approach since some time, so it should work. Has there been a change in the default settings for UIAxes or exportgraphics or what is going on?
Thanks in Advance.
Edit: With further testing I realized, that it's not the exportgraphics with the problem, but the plot is just not happening.
Edit2: I've updated to Update 6 and the problem still persists.
Edit3: It works as expected on R2022a, on the same PC.
  1 件のコメント
Adrian
Adrian 2024 年 1 月 25 日
I've retried the same code on another machine with Matlab R2023b Update 3, and it works again as expected.
That leads me to believe, there are some weird issues or settings on my main PC.

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

採用された回答

Adrian
Adrian 2024 年 1 月 25 日
It was an issue with OpenGL. Adding -nosoftwareopengl to the Startup solved the issue.
Dear Matlab: rendererinfo did not complete, hence it is not a substitute for the deprecated opengl info.

その他の回答 (1 件)

Anton Kogios
Anton Kogios 2024 年 1 月 24 日
編集済み: Anton Kogios 2024 年 1 月 24 日
When I run this code (from the command window), it all works fine (Windows 10, MATLAB R2023b Update 6). See attached image for result.
fig = uiaxes;
plot(fig, rand(1, 100))
exportgraphics(fig, 'ydklfg.png')
I know this is fairly obvious, but maybe trying restarting and/or updating both your OS and MATLAB.
  3 件のコメント
Adrian
Adrian 2024 年 1 月 24 日
I've updated to Update 6 and the problem still persists.
Anton Kogios
Anton Kogios 2024 年 1 月 24 日
Hi Adrian, thanks for updating and testing further. I would say to double check your UIAxes settings, but it's interesting that's it's working fine on R2022a for you...
I made a very simple app (attached) to try replicate your situation and it all works fine, maybe have a go at running it yourself.

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

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by