Clear Filters
Clear Filters

Exportgraphics does only export black images from UIAxes

4 views (last 30 days)
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 Comment
Adrian
Adrian on 25 Jan 2024
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.

Sign in to comment.

Accepted Answer

Adrian
Adrian on 25 Jan 2024
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.

More Answers (1)

Anton Kogios
Anton Kogios on 24 Jan 2024
Edited: Anton Kogios on 24 Jan 2024
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 Comments
Adrian
Adrian on 24 Jan 2024
I've updated to Update 6 and the problem still persists.
Anton Kogios
Anton Kogios on 24 Jan 2024
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.

Sign in to comment.

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!