Saving images in Python at a very high quality

后端 未结 5 801
北恋
北恋 2020-11-29 15:43

How can I save Python plots at very high quality?

That is, when I keep zooming in on the object saved in a PDF file, why isn\'t there any blurring?

Also, what

5条回答
  •  没有蜡笔的小新
    2020-11-29 16:09

    Just to add my results, also using Matplotlib.

    .eps made all my text bold and removed transparency. .svg gave me high-resolution pictures that actually looked like my graph.

    import matplotlib.pyplot as plt
    fig, ax = plt.subplots()
    # Do the plot code
    fig.savefig('myimage.svg', format='svg', dpi=1200)
    

    I used 1200 dpi because a lot of scientific journals require images in 1200 / 600 / 300 dpi, depending on what the image is of. Convert to desired dpi and format in GIMP or Inkscape.

    Obviously the dpi doesn't matter since .svg are vector graphics and have "infinite resolution".

提交回复
热议问题