[Matplotlib-users] matplotlib interactive in a shell terminal?

Raphael Raccuia rafael.raccuia at blindekinder.com
Mon May 18 19:11:55 EDT 2020


Ah, ok I get it. I'll give a try.
Puredata is a visual programming languate: http://puredata.info/, which 
has a lib to bind with Python 2.7.
It's related to my first question cause in both cases it doesn't 
display. So simply why does it work in Idle, but not in PD and shell?

rph

Le 19.05.20 à 01:04, Matt Newville a écrit :
> Hi Raphael,
>
> Sorry, I have no idea what Puredata is.  I thought your question was 
> about "linux shell terminal".
>
> Wxmplot is not another language, it is a simple python module with 
> functions called `plot()`, `imshow()`, and a few other functions for 
> extra tools.   It's not magic (and doesn't require any of the silly 
> IPython "magic").  From a usage point of view, I think it could not be 
> much simpler: it does not need `ion()` or `show()`.  Just `plot()`.
>
> But, maybe you're looking for something else.
> Cheers,
>
>
> On Mon, May 18, 2020 at 5:04 PM Raphael Raccuia 
> <rafael.raccuia at blindekinder.com 
> <mailto:rafael.raccuia at blindekinder.com>> wrote:
>
>     Thank you Matt,
>
>     since the visual of my plot is almost finished and nice, I'm not
>     sure I'll learn another language at the moment.
>
>     Anyway, I fixed my script to work with P2.7, and learned how to
>     use Puredata [pyext] object, but now I have the following issue,
>     related to the initial one:
>
>     plt.ion()
>     plt.plot([1, 2, 3, 4], [1, 4, 2, 3])
>     plt.show(block=True)
>
>     The plot is interactive, PD sends instructions to Python to fill
>     and modify. If */block/* = */True/*, it displays the plot in Tk
>     window, but since it's blocked, PD doesn't respond until I close
>     the window.
>     If /*block*/ = */False/*, Tk window appear, empty, and impossible
>     to close, but PD remains functional.
>
>     any idea how to fix that?
>     rph
>
>     Le 18.05.20 à 15:59, Matt Newville a écrit :
>>     Raphael,
>>
>>     Depending on your needs, you might find wxmplot useful. This
>>     supports non-blocking, interactive 2D plots and image display
>>     from a terminal Python or IPython session.  As the name might
>>     imply, it requires wxPython but is installed with `pip install
>>     wxmplot` if your Linux Python has wxPython available (Anaconda
>>     Python does).  With this installed, you can do
>>
>>       >>> import numpy as np
>>     >>> import wxmplot.interactive as wi
>>     >>> x = np.linspace(0, 20, 101)
>>     >>> wi.plot(x, np.sin(x), xlabel='t(s)')
>>     <wxmplot.interactive.PlotDisplay at 0x10db88678>
>>     >>> wi.plot(x, np.cos(x)*np.exp(-x/10))
>>     <wxmplot.interactive.PlotDisplay at 0x10db88678>
>>
>>     The first plot() there will show an interactive display of the
>>     plot and return the prompt.  The second plot() here add the trace
>>     on top of the first (you can add optional arguments to open a
>>     second plot window or draw to right-hand axes). The plot windows
>>     have drag-and-zoom and many configuration options for colors,
>>     themes, etc available after the plot has been displayed. There is
>>     also a `wxmpot.interactive.imshow()` to show an interactive
>>     false-color image of 2D data. See
>>     https://newville.github.io/wxmplot/interactive.html for more details.
>>
>>     Of course, these do not do everything available in matplotlib,
>>     but if you are doing basic 2D line plots or image display they
>>     should go a long way.  And you can grab that return value and its
>>     `PlotDisplay.panel.axes` (a matplotlib Axes) and
>>     `PlotDisplay.panel.fig` (a matplotib Figure) if you want to do
>>     more complicated things.
>>
>>     --Matt
>>
>>     On Mon, May 18, 2020 at 3:43 AM Raphael Raccuia
>>     <rafael.raccuia at blindekinder.com
>>     <mailto:rafael.raccuia at blindekinder.com>> wrote:
>>
>>         Hi,
>>         Any chance  to use matplotlib in a linux shell terminal?
>>
>>         if I make 'python3 my/script.py', it displays the plot but I
>>         have no
>>         prompt >>>.
>>         It works in Idle.
>>         That would be my test script:
>>
>>         #!/usr/bin/env python3 #otherwise loads a 'ghost': cursor
>>         turn to cross,
>>         but no window.
>>
>>         import matplotlib
>>         print(matplotlib.get_backend()) #print TkAgg in the terminal
>>
>>         import matplotlib.pyplot as plt
>>
>>         plt.ion()
>>
>>
>>         plt.plot([1, 2, 3, 4], [1, 4, 2, 3])
>>
>>         plt.show(block=True) #block=True: othewise it close
>>         immediately plot and
>>         terminal
>>
>>         thank you!
>>
>>         rph-r
>>
>>
>>         _______________________________________________
>>         Matplotlib-users mailing list
>>         Matplotlib-users at python.org <mailto:Matplotlib-users at python.org>
>>         https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>>
>>
>
>     _______________________________________________
>     Matplotlib-users mailing list
>     Matplotlib-users at python.org <mailto:Matplotlib-users at python.org>
>     https://mail.python.org/mailman/listinfo/matplotlib-users
>
>
>
> -- 
> --Matt Newville <newville at cars.uchicago.edu 
> <http://cars.uchicago.edu>> 630-252-0431

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20200519/96162792/attachment.html>


More information about the Matplotlib-users mailing list