【问题标题】:Saving a plot as a PNG in Matlab [duplicate]在Matlab中将绘图保存为PNG [重复]
【发布时间】:2012-05-15 17:51:59
【问题描述】:

我有一个绘制时间序列的函数,现在我想将其保存为图像,请问如何做到这一点?

function TimeSeriesImages(a, b, c, d, e, f, g, h, i, j, k, l)
x = [a b c d e f g h i j k l];
ts1 = timeseries(x,1:12);
ts1.Name = 'Monthly Count';
ts1.TimeInfo.Units = 'months';
ts1.TimeInfo.Format = 'mmm dd, yy'
ts1.Time=ts1.Time-ts1.Time(1);
plot(ts1)
end

【问题讨论】:

  • 可能与here有关。

标签: image matlab time-series


【解决方案1】:

在 Matlab 中保存图形的另一种方法是使用变量处理它们并稍后保存。

例如:

a=bar(...);
b=hist(...);   %some figures
c=plot(...);

saveas(a, 'path\to\file\abc1.png','png');
saveas(b, 'path\to\file\abc2.png','png');
saveas(c, 'path\to\file\abc3.png','png');

来自官方 Matlab 帮助的片段:

saveas - 使用指定格式保存图形或 Simulink 框图

语法

saveas(h,'filename.ext') 
saveas(h,'filename','format')

说明

saveas(h,'filename.ext') 将图形或 Simulink 框图保存为 文件filename.ext的句柄h。文件的格式由扩展名 ext 决定。 有关更多信息,请参阅 Matlab 帮助。

【讨论】:

    【解决方案2】:

    您可以将print-dpng 标志一起使用。

    【讨论】:

    • 更多信息请参见print in the Matlab Doc
    • 这个方法稍微好一点,你可以改变分辨率。
    • 这也消除了给每个情节/图形一个句柄的需要,很好
    猜你喜欢
    • 2011-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-31
    • 2016-06-11
    • 1970-01-01
    • 2018-11-06
    相关资源
    最近更新 更多