Colour changes from figure to png upon export

13 次查看(过去 30 天)
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 中查找有关 Axis Labels 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by