[Python] Matplotlib compiled .pgf output blurry

Discussão em 'Python' iniciado por Stack, Julho 1, 2025.

  1. Stack

    Stack Membro Participativo

    I am generating .pgf plots in matplotlib. Here a minimal example:

    import matplotlib.pyplot as pyplot
    import numpy.random as random

    pyplot.matshow(random.random((20, 20)), interpolation="none")
    pyplot.savefig("plot.pgf")


    This creates a .pgf file and a .png file which contains the actual image data. Notably, the png file is only 20x20 pixel large. Of course, it does not need to be larger, since these 20x20 pixel contain the full information of the plot.

    I the compile a latex document which includes this .pgf file:

    \documentclass{standalone}%
    \usepackage{pgf}%
    \begin{document}%
    \input{plot.pgf}%
    \end{document}%


    The resulting pdf looks like this (MacOS Preview):

    [​IMG]

    Clearly, this is not what should be displayed. Instead, Firefox shows this for example:

    [​IMG]

    Which is what I would have expected. Thus, this may be a Preview issue.

    Is there a way to fix this?

    Continue reading...

Compartilhe esta Página