I have a very strange problem that appeared recently, more or less simultaneously to my Ubuntu upgrade to 16.10.
Using Pyplot, when I use LaTeX in labels, Python3 gives back something very strange. For example, I tried to compile the example from
http://matplotlib.org/examples/text_labels_and_annotations/text_demo_fontdict.html
and I got this result:
I try to upgrade my matplotlib with pip, but nothing changed. Right now:
numpy=1.11.1, matplotlib=1.5.3
Interestingly, this problem disappears when I go back to python2, and the conversion is good.
Edit: on another machine, with Ubuntu 16.10 up-to-date, the same mpl and np versions, this bug appears in python3 AND python2.
EEdit : I did not find the problem, but a guess is a problem in the cm font of matplotlib. I tried to change the font (see e.g. How do I change the axis tick font in a matplotlib plot when rendering using Latex?), and the problem disappeared...
Thanks in advance for your help!
Related
I am using PyCharm on my MacBook to code and now I wanted to make a simple plot. When I run the file via the usual 'Run' command (do not know what it is called), it nicely shows my plots, but when I run the file in the Python console (which I find more convenient because you can access your variables) it does not show anything. On the other hand, when I just type it in the Python console afterwards, it does work.
I have read some things about backends and other 'solutions' as I am apparently not the only one with this issue. Mine says macosx and gives the command: "Backend MacOSX is interactive backend. Turning interactive mode on." after running the file in the Python console. I tried changing the backend:
import matplotlib
# matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
but that does not work (no plot pops up). And yes, I use plt.show() after my plotting section :)
I also tried with 'QtAgg' but then I get: "ImportError: Failed to import any qt binding"
Now I am completely new to this backends stuff (I think it has to do with this), so I could really use some clear directions on how I can solve this issue.
Thanks in advance!
I am not sure we can solve this bug with some adjustment. I think you need to fresh start. I suggest you to start a new clean venv and install a new matplotlib there.
There are questions referring to this same error message, but the crucial difference is that I am not (deliberately) using Qt. I don't actually know what it is, and I am trying to run my program on cmd, not through any IDE. I have been using matplotlib without any problems until just now, when i suddenly got the error message:
This application failed to start because it could not find or load the Qt platform plugin "windows"
in "".
Available platform plugins are: direct2d, minimal, offscreen, windows.
Reinstalling the application may fix this problem.
here is a sample program which produces this error, although I suspect it is a consequence of the package being used, not the program
import matplotlib.pyplot as plt
nums = [1,2,3,4]
labels = ["one","two","three","four"]
colours, one, two = plt.pie(nums, labels=labels, autopct='%1.1f%%')
plt.legend(colours, labels, loc="best")
plt.axis('equal')
plt.show()
again, I installed matplotlib years ago, and have been using it just fine until now. Any help would be greatly appreciated.
edit: python version 3.7.1, matplotlib version 3.1.1
Ok, I just fixed it by upgrading matplotlib to version 3.2.1
not sure why that worked but hey
As of late, I can't get my Matplotlib plots to show up. I have a very simple script:
import matplotlib.pyplot as plt
plt.plot([1,2,3])
but nothing ever shows up. If I include the line
plt.show()
then my Python process hangs.
In my ~/.config/matplotlib/matplotlibrc file I have
backend : MacOSX
interactive : True
I'm a little embarrassed to ask this question. I've been a Matplotlib user for many years and have never had this problem. I don't know where to begin to fix this problem. Help!
I'm using Matplotlib 2.0.0 with Python 3.5.2 from Anaconda.
The answer, as pointed out by #ImportanceOfBeingErnest is that the backend configuration for me wasn't working. I'm not sure if I need to install some additional libraries or not. I decided not to use the MacOSX backend and used the Qt5Agg backend. This worked just fine and I didn't have to install any new libraries.
I've just remove the line
interactive: True
enter code here
from my ~/matplotlib/matplotlibrc. It works fine with only backend: MacOSX using the plt.show() command.
After upgrading to Yosemite from Mountain Lion I've spent quite a bit of time getting all my packages working again, but I'm left with one weird issue. When I try to both save and show a matplotlib plot I get the following error:
Assertion failed: (s->stack->next != NULL), function CGGStackRestore, file Context/CGGStack.c, line 77.
The following short script produces this error, but works as expected if I comment out either the savefig or the show command.
import matplotlib.pyplot as pl
def main():
pl.plot(range(10),range(10))
pl.savefig('bugplot.jpg')
pl.show()
return
I'm using python 2.7, installed through homebrew, with my scipy, numpy and matplotlib packages all updated to the latest versions through pip. Saving a figure as well as showing it was working fine before I upgraded to Yosemite (and performed all the associated updates to xcode,homebrew,python,etc.), but I couldn't say exactly which versions I was using before. I can work around this problem of course, but it is bugging me, and I like getting a quick look at my figures while saving them, so any help would be much appreciated.
I want to try out the new .xkcd() function for matplotlib as shown here
http://matplotlib.org/xkcd/examples/showcase/xkcd.html
but it is not working because I think it only works for matplotlib 1.3. So I'm wondering how I would update to matplotlib 1.3. I tried
easy_install matplotlib
but that did not seem to work. Alternatively, if there is a way to use .xkcd() without updating, that would answer my question as well. Also, I am using windows.
On this page pick the version of python that you are using, download the exe and run it.