[Python] How do Matplotlib and TeX communicate?

Discussão em 'Python' iniciado por Stack, Novembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    This follows a recent post which got a few views and no reply at all. I have a system with Windows 11, Python 3.10.8 and Matplotlib 3.9.2 and MiKTeX 24.0. Until a couple of weeks ago, I was able to plot nice charts like this one:

    [​IMG]

    But not any more. Out of the blue, TeX stopped working. Now I get a strange error that seems to have nothing to do with a Windows system (after a lot of omitted lines):

    FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/texmf-dist/fonts/tfm/public/cm/cmr10.tfm'


    In this case, I was trying to use the Computer Modern Roman font.

    The point is: this is a Windows system, while "/usr/share/texmf-dist/fonts/..." is clearly a Linux path. How are those things related?

    My questions are, therefore:

    (1) Where from does Matplotlib fetch the TeX-style fonts? As I said, I have MiKTeX installed.

    (2) Is there a command that can tell me what is Matplotlib trying to do?

    (3) Could I change the Matplotlib configuration file to point to the TeX fonts?

    Don't get me wrong, though. A simple script like this one works nicely:

    from matplotlib import pyplot as plt
    import numpy as np

    x = np.linspace(-2.0*np.pi, 2.0*np.pi, 200)

    plt.figure(1)
    plt.xlabel("x")
    plt.ylabel("f(x)")
    plt.plot(x, np.cos(x), 'b.')
    plt.show()


    it's when I try to use TeX rendering that I get that error message and a blank plotting window.

    Any help will be much appreciated. I really don't know what to do. I have uninstalled and reinstalled everything more than once - to no avail.

    Thanks.

    Continue reading...

Compartilhe esta Página