필터 지우기
필터 지우기

saveas to pdf but get a blank

조회 수: 7 (최근 30일)
Yuqing_noob
Yuqing_noob 2023년 3월 21일
댓글: Anton Kogios 2023년 3월 30일
Hi,
I want to draw a 2-D curve with a gradient color and I found a tutorial from: https://stackoverflow.com/questions/31685078/change-color-of-2d-plot-line-depending-on-3rd-value . It works but I found I can not save the figure to pdf (I will get a blank).
The following is the code copy from the tutorial and tha last two lines is my code to save the figure:
figure;
n = 100;
x = linspace(-10,10,n); y = x.^2;
p = plot(x,y,'r', 'LineWidth',5);
%// modified jet-colormap
cd = [uint8(jet(n)*255) uint8(ones(n,1))].'; %'
drawnow
set(p.Edge, 'ColorBinding','interpolated', 'ColorData',cd)
%save figure
saveas(gcf,['test_V4.tiff'])
saveas(gcf,['test_V4.pdf'])
Any ideas of how to approach this? I did not use surface function because It looks strange in the curved turns after zoom out.
  댓글 수: 4
Anton Kogios
Anton Kogios 2023년 3월 23일
Interesting problem which I couldn't solve - the source of the issue seems to be changing the ColorBinding and exporting as a vectorised graphic.
Is a high-resolution image good enough for you? It's not vectorised but:
exportgraphics(h,'test_V4.pdf','ContentType','image','Resolution',600)
Yuqing_noob
Yuqing_noob 2023년 3월 23일
Hi Anton, thanks! Your are right, exportgraphics is a useful function. Currently I saved the figure in this way, and it works well! But I think a vectorised graphic is what I need. haha I think I can always use for loop to plot the gradient color if I can not solve this problem.

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

답변 (1개)

Raghunathraju
Raghunathraju 2023년 3월 30일
Hi Yuqing,
I understand that you are unable to save the figure to pdf using ‘saveas’ option. Instead, you can try print option or Ctrl+p to print the figure and save it as PDF.
  댓글 수: 1
Anton Kogios
Anton Kogios 2023년 3월 30일
I don't think that answers the question given that it won't be vectorised.

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

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by