简体   繁体   English

八度,如何保存情节图?

[英]Octave, how to save a plot graph?

I need to save a plot. 我需要保存一个情节。 This is my code that I don't know why it does not work. 这是我的代码,我不知道为什么它不起作用。

hold on;
plot(x1, y2)
plot(x1, y2)
print -djpg image.jpg

The plot in output on screen is correct, but the output in the file is different: it saves only an empty plot image without my points. 屏幕输出中的图是正确的,但文件中的输出是不同的:它只保存没有我的点的空图。

This is my output in the file: 这是我在文件中的输出: 在此输入图像描述

I just had the same issue with the latest Octave (3.8.1). 我对最新的Octave(3.8.1)也有同样的问题。 This issue comes from GhostScript, not Octave. 这个问题来自GhostScript,而不是Octave。 There's a bug with the management of fonts. 字体管理存在一个错误。

To make sure, check in your console after you try to print if this error is outputted (along with a lot more infos): 要确保,请在尝试打印后检查您的控制台是否输出此错误(以及更多信息):

GPL Ghostscript 8.63: Unrecoverable error, exit code 1

If that's the case, then try this: 如果是这种情况,那么试试这个:

set (0, "defaultaxesfontname", "Helvetica") % this is the line to add BEFORE plotting
hold on;
plot(x1, y2)
plot(x1, y2)
print -djpg image.jpg

This will fix the problem by setting a font that GhostScript can handle without any issue. 这将通过设置GhostScript可以毫无问题地处理的字体来解决问题。 Note that if you already plotted the figure, you will have to close it and replot it after setting defaultaxesfontname. 请注意,如果您已经绘制了图形,则必须将其关闭并在设置defaultaxesfontname后重新绘制它。

Source: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=710272 资料来源: https//bugs.debian.org/cgi-bin/bugreport.cgi?video = 710272

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM