Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX plots #14

Open
joriswitstok opened this issue Mar 30, 2021 · 7 comments
Open

LaTeX plots #14

joriswitstok opened this issue Mar 30, 2021 · 7 comments

Comments

@joriswitstok
Copy link
Contributor

When using the plotting functions, I run into the following problem:

RuntimeError: latex was not able to process the following string:
b'lp'

I'm aware this is an issue with my local LaTeX distribution (MiKTeX in my case), but a few Google searches have not solved the problem yet (all executables of LaTeX, Ghostscript, and dvipng are in /usr/local/bin which is included in PATH). Is there a way to turn off plotting with TeX to overcome the problem?

@ACCarnall
Copy link
Owner

ACCarnall commented Mar 30, 2021

Hi Joris,

Thanks for getting in touch! The code is designed so that it picks up on whether you have text.usetex enabled in matplotlibrc and acts accordingly. So if you turn off latex processing it should automatically stop trying to use it, and replace the axis labels with non-latex versions. That said, it's not exactly well tested functionality, so let me know if you have trouble.

Cheers,
Adam

@joriswitstok
Copy link
Contributor Author

Hi Adam,

That's convenient! But I think I have text.usetex turned off in the default matplotlib rcParams, and even when setting it to False explicitly (as in the below code snippet), the error persists?

plt.rcParams["text.usetex"] = False
fig = fit.plot_spectrum_posterior(save=False, show=True)

Let me know if you can think of a reason why this would be. (For completeness, I have set up a conda environment with python version 3.7.10, matplotlib version 3.3.4, having installed bagpipes 0.8.5 through pip.)

Cheers,
Joris

@ACCarnall
Copy link
Owner

Hi Joris,

Hmm, ok I just looked back at the code (lines 17-20 of bagpipes/plotting/general.py) and it looks like the way I implemented turning latex on or off was to check whether there's an executable called latex in your environment. This will overwrite text.usetex, which isn't ideal, I should probably change the way this is done. Can you try changing lines 105 and 106 in that file to turn latex off even if there's a latex distribution in your path, and see if that fixes it?

I have a vague memory of getting this error before, but it might just be the power of suggestion. I think perhaps the solution was to re-install latex. I googled "b'lp' error python" and found some useful threads. One suggestion seems to be that you're missing dvipng?

Cheers,
Adam

@joriswitstok
Copy link
Contributor Author

Hi Adam,

Setting tex_on in line 17 to False manually does avoid the error (the only problem being some of the labels are not typeset in latex, as expected).

Yes, that's what I read, too – but as far as I can tell, dvipng should come with the MiKTeX installation, and its executable is located in /usr/local/bin... I might try to reinstall the latex distribution to see if that helps.

Cheers,
Joris

@ACCarnall
Copy link
Owner

Good good, yeah I'm forever having trouble with latex installations, good luck sorting it!

@thriveth
Copy link

I still see that Bagpipes turns on LaTeX when plotting even if I do not have it turned on in my standard environment. Could it be set to not turn it on by default and then only do so when explicitly asked to, in accordance with the principle of least surprise?

@ACCarnall
Copy link
Owner

Yes, I should get round to fixing this as I said I would. I've reopened this issue to remind myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants