I'm trying to display the results of a simple function animated over time. There are many examples of this on matplotlib and stackoverflow (typical link below). All of these produce the same dysfunctionality: the axes appear, but the data doesn't: the content of the plot is blank. I'm literally copying and pasting tutorial code, so it seems likely to be a configuration issue, rather than a coding error.
A number of similar problems have been reported, but none of the answers seem to work. I'm on a current Mac with OSX 10.13.4, running python 3.6.5 and recently updated matplotlib. Per suggestions from other questions I've set up a Framework installation of python 3.6.5, straight from python.org. No change in behavior running outside or within a virtual environment (tried virtualenv and venv).
I haven't encountered problems with plots that don't attempt to animate - they work fine.
I've tried running many examples from the command line (bash), the PyCharm IDE, and in Jupyter, with same result (everything but animations works). There are no error messages except for examples that attempt to save images - those crash with a long error log (e.g. Animating "growing" line plot in Python/Matplotlib produces "ValueError: Invalid file object: <_io.BufferedReader name=65>" after pages of traceback). In such examples commenting out the save prevents the crash, but the plot remains empty.
Advice much appreciated.
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.
I'm using:
Python 2.7.3
matplotlib 1.4.1
Spyder IDE 2.3.8
My code has to produce a chart (combination of bar and scatter) . First run on the code succeeds in that, however all following executions (both run or debug) produce just an empty chart with correct grid, label, and legend, but no bars not scatter plot. I have to close Python console and open a new one to get the correct plot, and then the story repeats. In debugger I can see that all the data for the chart is fine.
I also tried Wing IDE (ver 5.1.10-1), and the very same code works fine all the time.
I found some suggestions about setting console preferences in Spyder (ie set GUI backend to Qt4Agg, agg, TkAgg, MAcOSX, Inline and such - none of those had any effect)
I would appreciate any help with this, as I'd prefer to use Spyder.
Many thanks
P.S. I used an earlier version of matplotlib without any issues, but recently I had to update it to ver 1.4.1 to use some libraries in an unrelated software project.
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.
When I am using pylab in ipython notebook I try to close a figure and nothing happens except the toolbar with the pan and zoom options disappears. After this happens when I attempt to plot a new figure I get this:
PyAssertionError: C++ Assertion "wxAssertFailure" failed at ....\crc\msw\app.cpp(703) in wxAPP() Yield called recursively.
There is probably a lot of other output in the cmd window that I could post here as well if it helps. I've seen a solution to this problem here:
https://github.com/ipython/ipython/issues/3553/
Which was to set --pylab=wx when starting the notebook but this does not work for me. Does anyone have any ideas on how to solve this? I've been having a lot of trouble with EPD trying to get Cython to work with mingw as well...I wonder if somehow it's related. I ran the same code with my Anaconda distribution and I have no problems so I'm not quite sure where to begin on this one.
I have been struggling a lot with matplotlib. Some solutions have already been given for my problem here - matplotlib does not show my drawings although I call pyplot.show()
I have tried all possible suggested backend however, code compiles with no errors for many backends. For some I get errors. I also tried with virtalenv but no luck with it too. Is there something I am missing.
Ubuntu 12.04
python 2.7.3
following is the output of running a sample graph file in verbose mode:
matplotlib version 1.2.1
verbose.level helpful
interactive is False
platform is linux2
Using fontManager instance from /home/ravi/.matplotlib/fontList.cache
backend agg version v2.2
I would really appreciate any suggestion or link to solutions. I have already tried all possible backends.
You should first make sure that you use the right backend. If you run IPython, the backend is normally displayed at start time. You can also get it with print matplotlib.get_backend().
If the backend is not the one you want, you can do matplotlib.use('backend name') first thing, where the backend name is from the matplotlib.rcsetup.all_backends list (not all backends work; for instance, the template backend is supposed to not do anything, but it allows you to check that your code runs). You can set the default backend as explained in the question you linked to.
I'm not sure if the following can help too, but have you tried to use matplotlib.pylot.ion(), which switches to interactive mode?