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

Matt Newville newville at cars.uchicago.edu
Sun May 24 19:50:17 EDT 2020


Raphael,



On Sun, May 24, 2020, 3:43 PM Raphael Raccuia <
rafael.raccuia at blindekinder.com> wrote:

> 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
>


Sorry, I cannot tell what that means.  Can you be very clear about what you
did and what error message you get.  For sure, the intention is that `pip
install wxmplot` will work, as this is a pure python module, but there are
many ways that things can go wrong. Please verify that you can install
other python modules too.

Like Tom said, if this is some embedded python environment, there may be
conflicts between the event loops.  Also, of this is some embedded
environment, verify that you are installing to the right place.




> 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> 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
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> 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/dd56db7e/attachment-0001.html>


More information about the Matplotlib-users mailing list