Colour changes from figure to png upon export

조회 수: 8 (최근 30일)
Ahmed Abdulla
Ahmed Abdulla 2022년 1월 5일
답변: DGM 2022년 1월 5일
Hi everyone, I am generating a plot using the code below where the lines plotted in the loops are in white and with a width of 0.2, however upon exporting the figure as a png the lines are exported in black. Does anyone know why the colour in the figure is different to the figure in the png
figure(1)
scatter(Table(:,2),Table(:,1),5,Table(:,3))
colormap('gray')
set(gca,'DataAspectRatio',[1 1 1])
set(gca,'fontsize',18)
xtickangle(45)
xlim([0 1800])
ylim([317 715])
for i=1:17
hold on
line([1,1800],[i*100,i*100],'Color','white','LineWidth',0.2)
end
for i=0:36
hold on
line([i*100,i*100],[0 900],'Color','white','LineWidth',0.2)
end
print(gcf,'Grids2','-dpng','-r1000');
  댓글 수: 1
DGM
DGM 2022년 1월 5일
I can't seem to replicate the issue. For me, in R2019b, it exports with white lines.
The image is large (about 6000x7000px), so some viewers may be causing issues with nearest-neighbor display interpolation, so some features tend to disappear at most zoom levels. Still, that shouldn't be adding black lines.

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

답변 (1개)

DGM
DGM 2022년 1월 5일
I'm going to go out on a limb and guess that you're setting the axes color to something other than white.
set(gca,'color','r') % something like this?
Otherwise, the white grid would be invisible. If that's the case, then this may help:
set(gcf, 'InvertHardcopy', 'off')
and then call print().

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by