Colour changes from figure to png upon export
8 次查看(过去 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
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
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().
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!