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 Center および File ExchangeGeographic Plots についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by