将MATLAB图形保存为特定的分辨率 [英] Saving MATLAB graphs in a specific resolution
问题描述
如何更改MATLAB图形的分辨率?默认值似乎是96x96 PPI .
How do I change the resolution of my MATLAB graphs? The default seems to be 96x96 PPI.
推荐答案
您可以使用print
命令进行保存;方法如下:
You can save using the print
command; here's how:
h1=figure;
your plotting commands here
print(h1,'-djpeg','-r150','filename')
-r150
参数将分辨率设置为150 DPI.您可以根据需要将其设置为更高或更低.这是假设您要另存为JPEG.如果没有,则还有其他选项,例如PNG的-dpng
,24位位图的-dbmp
等.在print
的帮助部分中可以找到更多选项.
The -r150
argument sets the resolution to 150 DPI. you can set it higher or lower depending on your need. This is assuming you're saving as a JPEG. If not, there are other options such as -dpng
for PNG, -dbmp
for 24-bit bitmap, etc. more can be found in the help section for print
.
也就是说,如果您的绘图仅由线条组成,我建议您使用-depsc
将其另存为EPS文件,该文件具有可伸缩性和无损性.您也不必定义分辨率,因此只需完成
That said, if your plot consists only of lines, I would recommend using -depsc
which saves it as an EPS file, which is scalable and lossless. You also won't have to define a resolution, so you can simply do
print(h1,'-depsc','filename')
您可以将此EPS文件转换为PDF,并保持相同的分辨率,但在应用程序和平台之间具有可移植性.我不建议直接保存为PDF,因为MATLAB会在绘图周围放置额外的空白,EPS边界框很紧,而且看起来很整洁.
You can convert this EPS file to PDF and retain the same resolution, yet have portability between applications and platforms. I wouldn't recommend saving to PDF directly as MATLAB puts additional white spaces around the plot, wheras the EPS bounding box is tight, and looks neat.
这篇关于将MATLAB图形保存为特定的分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!