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

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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

Hi Raphael,

Have you seen IPython? It was created precisely for this use case.

http://ipython.org/

Depending on your setup, you will want to `pip install ipython`, `conda install ipython`, or `sudo apt install ipython`. (I don't recommend `sudo pip install [anything]`.)

Once you are in IPython, you can run your script with `%run -i my_script.py`, and get your prompt, from which you can control the plot or create other plots.

I also recommend you use conda environments for development:

https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html

I hope this helps!

Juan.

···

On Mon, 18 May 2020, at 3:33 AM, Raphael Raccuia 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@python.org
Matplotlib-users Info Page

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

Hi,
thank you for your answers!

I saw about ipython, I would have used that but I use the [shell] object in Puredata (music object programmation language) which just send commands to terminal, that's why...
There is a Python object, but only works with 2.7.

rph-r

···

Le 18.05.20 à 11:08, Juan Nunez-Iglesias a écrit :

Hi Raphael,

Have you seen IPython? It was created precisely for this use case.

http://ipython.org/

Depending on your setup, you will want to `pip install ipython`, `conda install ipython`, or `sudo apt install ipython`. (I don't recommend `sudo pip install [anything]`.)

Once you are in IPython, you can run your script with `%run -i my_script.py`, and get your prompt, from which you can control the plot or create other plots.

I also recommend you use conda environments for development:

Getting started with conda — conda 23.10.1.dev72 documentation

I hope this helps!

Juan.

On Mon, 18 May 2020, at 3:33 AM, Raphael Raccuia 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@python.org
Matplotlib-users Info Page

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@python.org
Matplotlib-users Info Page

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

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@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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

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@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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

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@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@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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users


Matplotlib-users mailing list
Matplotlib-users@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

–Matt Newville <newville at cars.uchicago.edu> 630-252-0431

Ah, ok I get it. I'll give a try.
Puredata is a visual programming languate: , 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

···

http://puredata.info/

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@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@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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users


Matplotlib-users mailing list
Matplotlib-users@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

–Matt Newville <newville at cars.uchicago.edu> 630-252-0431

The issue you are having is that you need integrate the two event loop (the prompt and the GUI) in a way that they will time share. Please see https://github.com/matplotlib/matplotlib/pull/4779 (which hopefully we can get merged soon so I can start linking people to the docs rather than a PR) for details.

The reason that it works in IDLE is that IDLE sets up the hooks to integrate Python prompt and Tk event loop.

The IPython magics let you select which GUI event loop you would like to integrate with the terminal.

Similarly, someplace inside wxmplot the input hook is being set up for Wx (either implicitly or explicitly).

To get this working inside of puredata you should reach out to them and ask about how to talk to their GUI from Python and then make sure that you use the backend that matches that framework. From a very very cursory glance at their website it looks like they have a GUI application with a captive python interpreter so I suspect if you can create a window in the correct toolkit, it will work (because the thing outside of the Python prompt is already running the GUI).

Tom

···

Thomas Caswell
tcaswell@gmail.com

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@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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

Raphael,

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.

···

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

``

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@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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users


Matplotlib-users mailing list
Matplotlib-users@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

Thank you Matt,

I did in a terminal. Also tried with , but it’s worse, compilation errors by embedded environment, you mean the pyext in Puredata? I did all the tests in a terminal first, and then in PD: The behaviour is the same. rph

···

Le 25.05.20 à 01:50, Matt Newville a écrit :

Raphael,

On Sun, May 24, 2020, 3:43 PM Raphael Raccuia <rafael.raccuia@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.

sudo pip install wxmplot*$ python -m pip install wxmplot*

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@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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users


Matplotlib-users mailing list
Matplotlib-users@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

Try

ipython --pylab

in a shell terminal.

/gostal

···

Från: Matplotlib-users matplotlib-users-bounces+gostal=foi.se@python.org för Raphael Raccuia rafael.raccuia@blindekinder.com
Skickat: den 18 maj 2020 10:33:53
Till: matplotlib-users@python.org
Ämne: [Matplotlib-users] matplotlib interactive in a shell terminal?

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@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users