Filter löschen
Filter löschen

Exportgraphics does only export black images from UIAxes

12 Ansichten (letzte 30 Tage)
Adrian
Adrian am 24 Jan. 2024
Beantwortet: Adrian am 25 Jan. 2024
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 Kommentar
Adrian
Adrian am 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Adrian
Adrian am 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.

Weitere Antworten (1)

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by