Heim  >  Fragen und Antworten  >  Hauptteil

python – So ändern Sie den Pfad von matplotlib.pyplot.save

Standardmäßig wird es immer im selben Ordner wie die py-Datei gespeichert. Wie kann ich den Pfad ändern und das generierte Bild im gewünschten Pfad speichern?

为情所困为情所困2710 Tage vor1423

Antworte allen(1)Ich werde antworten

  • PHPz

    PHPz2017-05-18 10:47:14

    在matplotlib中,pyplot没有save函数,如果是保存图片的话,可以参考下面简单的例子:

    >>> from matplotlib import pyplot as plt
    >>> x=[2,5]
    >>> y=[4,9]
    >>> plt.plot(x,y)
    >>> plt.savefig('D:\img.jpg')

    当然你也可以保存为PDF格式:

    >>> plt.savefig('D:\img.pdf')

    关于这部分工作matplotlib会自动处理。

    Antwort
    0
  • StornierenAntwort