Saving images in Python at a very high quality

后端 未结 5 782
北恋
北恋 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 15:55

    If you are using Matplotlib and are trying to get good figures in a LaTeX document, save as an EPS. Specifically, try something like this after running the commands to plot the image:

    plt.savefig('destination_path.eps', format='eps')
    

    I have found that EPS files work best and the dpi parameter is what really makes them look good in a document.

    To specify the orientation of the figure before saving, simply call the following before the plt.savefig call, but after creating the plot (assuming you have plotted using an axes with the name ax):

    ax.view_init(elev=elevation_angle, azim=azimuthal_angle)
    

    Where elevation_angle is a number (in degrees) specifying the polar angle (down from vertical z axis) and the azimuthal_angle specifies the azimuthal angle (around the z axis).

    I find that it is easiest to determine these values by first plotting the image and then rotating it and watching the current values of the angles appear towards the bottom of the window just below the actual plot. Keep in mind that the x, y, z, positions appear by default, but they are replaced with the two angles when you start to click+drag+rotate the image.

提交回复
热议问题