如何将 Matlab 直方图保存为矢量图形?
How to save a Matlab histogram as vector graphic?
像这样保存直方图时:
x = randn(10000,1);
h = histogram(x)
saveas(gcf, 'test','epsc')
生成的后记包含某种形式的原始
位图。当嵌入到 pdf 中时,这看起来真的很丑。
如何将直方图保存为矢量图形?
我找到了两种继续下去的方法:
set(h,'FaceAlpha',1)
删除所有透明效果,matlab 可以将其保存为 postscript 文件。
将文件另存为 svg
saveas(gcf, 'test','svg')
并导入 Inkscape(或您选择的其他程序)并从那里导出为 eps 文件。
您也可以将图保存为使用矢量图形的 pdf。
x = randn(10000,1);
h = histogram(x);
% set proper paper size before generating pdf
set(gcf, 'Units', 'Inches');
pos = get(gcf, 'Position');
set(gcf, 'PaperPositionMode', 'Auto', 'PaperUnits', 'Inches', 'PaperSize', [pos(3), pos(4)]);
print(gcf, 'test.pdf', '-dpdf', '-r0');
免责声明 当我在 LaTeX 文档中嵌入图形时,我经常使用这段代码,但我很确定我是从网上的某个地方复制的(可能是这样)。
像这样保存直方图时:
x = randn(10000,1);
h = histogram(x)
saveas(gcf, 'test','epsc')
生成的后记包含某种形式的原始 位图。当嵌入到 pdf 中时,这看起来真的很丑。
如何将直方图保存为矢量图形?
我找到了两种继续下去的方法:
set(h,'FaceAlpha',1)
删除所有透明效果,matlab 可以将其保存为 postscript 文件。
将文件另存为 svg
saveas(gcf, 'test','svg')
并导入 Inkscape(或您选择的其他程序)并从那里导出为 eps 文件。
您也可以将图保存为使用矢量图形的 pdf。
x = randn(10000,1);
h = histogram(x);
% set proper paper size before generating pdf
set(gcf, 'Units', 'Inches');
pos = get(gcf, 'Position');
set(gcf, 'PaperPositionMode', 'Auto', 'PaperUnits', 'Inches', 'PaperSize', [pos(3), pos(4)]);
print(gcf, 'test.pdf', '-dpdf', '-r0');
免责声明 当我在 LaTeX 文档中嵌入图形时,我经常使用这段代码,但我很确定我是从网上的某个地方复制的(可能是这样)。