matplot plot hangs

Tim Williams tjandacw at cox.net
Thu Nov 2 08:28:49 EDT 2017


On Wednesday, November 1, 2017 at 6:30:27 PM UTC-4, Andrew Z wrote:
> nope. it doesnt:
> 
> I added print-s after each line and that produced:
> [az at hp src]$ cat ./main1.py
> import matplotlib.pyplot as plt
> print("imported")
> plt.plot([1,2,4,1])
> print("plot is done")
> plt.show()
> print("show is done")
> 
> [az at hp src]$ python3.5 ./main1.py
> imported
> ^C^Z
> [1]+  Stopped                 python3.5 ./main1.py
> 
> 
> On Wed, Nov 1, 2017 at 9:31 AM, Vlastimil Brom <vlastimil.brom at gmail.com>
> wrote:
> 
> > 2017-11-01 13:49 GMT+01:00 Andrew Z <formisc at gmail.com>:
> > > Wolfgang,
> > >  I tried to ran from ide with no rwsults, so now im trying from a
> > terminal
> > > in xwindow.
> > > The .plot is the last line in the script and it does hang trying to
> > execute
> > > it.
> > >
> > >
> > > On Nov 1, 2017 05:44, "Wolfgang Maier" <
> > > wolfgang.maier at biologie.uni-freiburg.de> wrote:
> > >
> > > On 01.11.2017 00:40, Andrew Z wrote:
> > >
> > >> hello,
> > >>   learning python's plotting by using matplotlib with python35 on
> > fedora 24
> > >> x86.
> > >>
> > >> Installed matplotlib into user's directory.
> > >> tk, seemed to work -
> > >> http://www.tkdocs.com/tutorial/install.html#installlinux - the window
> > >> shows
> > >> up just fine.
> > >> but when trying to run the simple plot (
> > >> https://matplotlib.org/examples/pylab_examples/simple_plot.html) the
> > >> script
> > >> is hanging on;
> > >>
> > >> plt.plot(t, s)
> > >>
> > >> attempts to
> > >> matplotlib.interactive(True) didn't bring anything,
> > >>
> > >>
> > > Hi Andrew,
> > >
> > > From which environment are you trying to run the example? In the
> > terminal,
> > > from within some IDE, inside a jupyter notebook?
> > >
> > > Are you sure the script "is hanging on plt.plot(t, s)" and not after
> > that?
> > >
> > > Best,
> > > Wolfgang
> > >
> > > --
> > Hi,
> > sorry if it is too trivial, just to make sure, do you have a call to
> > "show()" the resulting plot in the code?
> >
> > An elementary plotting code might be e.g.:
> >
> > import matplotlib.pyplot as plt
> > plt.plot([1,2,4,1])
> > plt.show()
> >
> > Does this work in your environment?
> >
> > It was not quite clear, what do you plan with interactive drawing, or
> > whether you are using e.g. plt.interactive(True) already - this might
> > be a problem as there could be collisions or the plot window is closed
> > after the standalone script finishes.
> >
> > hth,
> >  vbr
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >

Have you tried 

plt.show(block=False)
?



More information about the Python-list mailing list