Exportgraphics does only export black images from UIAxes

조회 수: 7 (최근 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 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