[Matplotlib-users] matplotlib interactive in a shell terminal?
Raphael Raccuia
rafael.raccuia at blindekinder.com
Sun May 24 16:43:15 EDT 2020
Hi Matt,
I can't install *wxmplot*, not in Ubuntu repositories and pip gives:
/Command "python setup.py egg_info" failed with error code 1 in
/tmp/pip-build-Ch6MUi/wxmplot/
??
/rph-r/
/
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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20200524/7a6b0b73/attachment.html>
More information about the Matplotlib-users
mailing list