How do you improve matplotlib image quality?

后端 未结 1 1469
不知归路
不知归路 2021-02-12 21:14

I am using a python program to produce some data, plotting the data using matplotlib.pyplot and then displaying the figure in a latex file.

I am currently saving the fi

相关标签:
1条回答
  • 2021-02-12 21:43

    You can save the images in a vector format so that they will be scalable without quality loss. Such formats are PDF and EPS. Just change the extension to .pdf or .eps and matplotlib will write the correct image format. Remember LaTeX likes EPS and PDFLaTeX likes PDF images. Although most modern LaTeX executables are PDFLaTeX in disguise and convert EPS files on the fly (same effect as if you included the epstopdf package in your preamble, which may not perform as well as you'd like).

    Alternatively, increase the DPI, a lot. These are the numbers you should keep in mind:

    • 300dpi: plain paper prints
    • 600dpi: professional paper prints. Most commercial office printers reach this in their output.
    • 1200dpi: professional poster/brochure grade quality.

    I use these to adapt the quality of PNG figures in conjunction with figure's figsize option, which allows for correctly scaled text and graphics as you improve the quality through dpi.

    0 讨论(0)
提交回复
热议问题