필터 지우기
필터 지우기

Problem with saving surf plot in vector format

조회 수: 23 (최근 30일)
Bogdan Nikitchuk
Bogdan Nikitchuk 2024년 1월 29일
댓글: Austin M. Weber 2024년 1월 29일
I have a 3D surf plot (view from the top) which consists of many points (nodes). First, I tried to save it as a .svg file. The file has a .svg type, however, it is a raster one in reality. I found out that adding the code
set(gcf, 'Renderer', 'Painters');
may help. For 2D plots, it worked well, but in my case, it opens the figure (in Matlab) pretty slowly and after the saving, it looks weird (the colours are dull and there are many "holes" in the figure) --- see screenshots below.

답변 (1개)

Austin M. Weber
Austin M. Weber 2024년 1월 29일
It is odd, but even though MATLAB allows you to save plots as SVG files I am not certain that it allows you to import SVG files.
The following is not a solution if you need the file to be in a vector graphics format, but if all you want is for the image to be high resolution then you can save your figure as a high-resolution PNG file and read it normally:
%% Generate 3D surface plot with a top-down view
[X,Y] = meshgrid(-5:.05:5);
Z = Y.*sin(X) - X.*cos(Y);
s = surf(X,Y,Z,'EdgeColor','none');
colorbar
view([90 90])
%% Export high-resolution png
exportgraphics(gcf,'figure.png',Resolution=600);
%% Import image and display
img = imread('figure.png');
imshow(img)
  댓글 수: 2
Bogdan Nikitchuk
Bogdan Nikitchuk 2024년 1월 29일
@Austin M Weber Thank you for the idea. However, it looks like this function was introduced in 2020a version.
Austin M. Weber
Austin M. Weber 2024년 1월 29일
@Bogdan Nikitchuk If you want, you can plug the code into MATLAB Online which automatically uses the most up-to-date version of MATLAB. That way you don't have to download a new Desktop version just to use the one function.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by