필터 지우기
필터 지우기

Dashed contours in a .eps figure appear solid

조회 수: 3 (최근 30일)
Jason
Jason 2011년 2월 3일
I am producing some figures for a publication and I am looking to create a contour plot with positive values in solid contours, negative values in dashed contours, and then shading for 95% significant values. I have set up the code to do this, but the dashed contours do not appear in the figure on screen or in the saved .eps file.
Here is the code I have used:
figure(1);
colormap(getpmap(4)); %This is a special colormap I have.
contourf(sst.lon,sst.lat,siglev,0.99:0.01:1.01);
contour(sst.lon,sst.lat,siglev,0.99:0.01:1.01);
contour(sst.lon,sst.lat,sst.cCPW(:,:,13).*sst.mask,...
-0.9:0.2:-0.1,'k--','LineWidth',2);
contour(sst.lon,sst.lat,sst.cCPW(:,:,13).*sst.mask,...
0.1:0.2:0.9,'k-','LineWidth',2);
print('SST_Correlation.eps','-depsc','-loose','-r1200');
Of course the problem is that the dashed lines appear as solid. I have read that this is an issue with the painters renderer, but when I switch to another renderer (zbuffer or opengl) and try to render a .eps, the file is gigantic in size. I tried rendering as a .jpg and .png but the quality of the image is not that great.
Can anyone help me with getting a .eps file (of reasonable size) with the dashed contours showing correctly?
  댓글 수: 1
Oliver Woodford
Oliver Woodford 2011년 2월 4일
Jason, no need to put "Help" in your question. Every question is asking for help! Also, your code cannot be run by anyone - we don't have getmap, stt or siglev. Can you change it for a simple script that exhibits the same problem and can be run by anyone with a standard MATLAB installation?

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

답변 (2개)

Bjorn Gustavsson
Bjorn Gustavsson 2011년 10월 24일
Ok, I just happened to have to deal with this ordeal. Here is a solution that gets the job done:
% Make the contours (and let matlab draw them):
[c1,h1] = contour(x,y,Z,'k-');
% Take all the info from the contourline output argument:
i0 = 1;
i2 = 1;
while i0 < length(cc1)
i1 = i0+[1:cc1(2,i0)];
zLevel(i2) = cc1(1,i0);
hold on
% And plot it with dashed lines:
ph(i2) = plot(cc1(1,i1),cc1(2,i1),'k--','linewidth',2);
i0 = i1(end)+1;
i2 = i2+1;
end
% Scrap the contourlines:
delete(h1)
Then continue with personal decorations et al.
HTH.

Jan
Jan 2011년 2월 4일
You can insert NaNs in your data. The corresponding points are not drawn:
a = peaks;
a(rand(size(a)) < 0.1) = NaN;
[c, h] = contour(a);
For complicated data, this might be impossible, because it is hard to find suiting positions for the gaps.

카테고리

Help CenterFile Exchange에서 Surfaces, Volumes, and Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by