Exportgraphics does only export black images from UIAxes

9 次查看(过去 30 天)
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 个评论
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 CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by