jktr / matplotlib-backend-notcurses Goto Github PK
View Code? Open in Web Editor NEWshow matplotlib plots directly in your terminal
License: Creative Commons Zero v1.0 Universal
show matplotlib plots directly in your terminal
License: Creative Commons Zero v1.0 Universal
Hi, I've tried installing according to the instructions on pypi and also via cloning your repo into the site-packages directory. I try to run the example you have outlined on your splash page.
$ export MPLBACKEND='module://matplotlib-backend-notcurses'
$ python -i
import numpy as np; import pandas as pd
n = 10000
df = pd.DataFrame({'x': np.random.randn(n),
'y': np.random.randn(n)})
df.plot.hexbin(x='x', y='y', gridsize=20)
However, my results copied from ipython below illustrate what is happening to me, no graphic is shown, instead I get the following output below.
In [5]: df.plot.hexbin(x='x', y='y', gridsize=20)
Out[5]: <AxesSubplot: xlabel='x', ylabel='y'>
Here's the traceback after keyboard interrupt (using I'm using python 3.11.1
with ipython 8.8.0
). I waited minutes, but nothing happened.
[ins] In [5]: plt.show()
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
Cell In[5], line 1
----> 1 plt.show()
File ~/.pyenv/versions/3.11.1/lib/python3.11/site-packages/matplotlib/pyplot.py:421, in show(*args, **kwargs)
377 """
378 Display all open figures.
379
(...)
418 explicitly there.
419 """
420 _warn_if_gui_out_of_main_thread()
--> 421 return _get_backend_mod().show(*args, **kwargs)
File ~/.pyenv/versions/3.11.1/lib/python3.11/site-packages/matplotlib-backend-notcurses/__init__.py:78, in _BackendNotcursesAgg.show(cls, *args, **kwargs)
76 @classmethod
77 def show(cls, *args, **kwargs):
---> 78 _Backend.show(*args, **kwargs)
79 Gcf.destroy_all()
File ~/.pyenv/versions/3.11.1/lib/python3.11/site-packages/matplotlib/backend_bases.py:3541, in _Backend.show(cls, block)
3539 for manager in managers:
3540 try:
-> 3541 manager.show() # Emits a warning for non-interactive backend.
3542 except NonGuiException as exc:
3543 _api.warn_external(str(exc))
File ~/.pyenv/versions/3.11.1/lib/python3.11/site-packages/matplotlib-backend-notcurses/__init__.py:29, in FigureManagerNotcurses.show(self)
23 margins = '0'
25 if os.environ.get('MPLBACKEND_NOTCURSES_SIZING', 'automatic') != 'manual':
26
27 # gather terminal dimensions
28 # FIXME should use a less hacky way for getting width/height in pixels
---> 29 info = run(['notcurses-info'], text=True, capture_output=True).stdout.rstrip()
30 dims = info.splitlines()[1].split(' ')
31 rows, height, width = map(int, [dims[0].split('[K')[-1], *dims[6].split('x')])
File ~/.pyenv/versions/3.11.1/lib/python3.11/subprocess.py:550, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
548 with Popen(*popenargs, **kwargs) as process:
549 try:
--> 550 stdout, stderr = process.communicate(input, timeout=timeout)
551 except TimeoutExpired as exc:
552 process.kill()
File ~/.pyenv/versions/3.11.1/lib/python3.11/subprocess.py:1207, in Popen.communicate(self, input, timeout)
1204 endtime = None
1206 try:
-> 1207 stdout, stderr = self._communicate(input, endtime, timeout)
1208 except KeyboardInterrupt:
1209 # https://bugs.python.org/issue25942
1210 # See the detailed comment in .wait().
1211 if timeout is not None:
File ~/.pyenv/versions/3.11.1/lib/python3.11/subprocess.py:2059, in Popen._communicate(self, input, endtime, orig_timeout)
2052 self._check_timeout(endtime, orig_timeout,
2053 stdout, stderr,
2054 skip_check_and_raise=True)
2055 raise RuntimeError( # Impossible :)
2056 '_check_timeout(..., skip_check_and_raise=True) '
2057 'failed to raise TimeoutExpired.')
-> 2059 ready = selector.select(timeout)
2060 self._check_timeout(endtime, orig_timeout, stdout, stderr)
2062 # XXX Rewrite these to use non-blocking I/O on the file
2063 # objects; they are no longer using C stdio!
File ~/.pyenv/versions/3.11.1/lib/python3.11/selectors.py:415, in _PollLikeSelector.select(self, timeout)
413 ready = []
414 try:
--> 415 fd_event_list = self._selector.poll(timeout)
416 except InterruptedError:
417 return ready
KeyboardInterrupt:
> /home/fbence/.pyenv/versions/3.11.1/lib/python3.11/selectors.py(415)select()
413 ready = []
414 try:
--> 415 fd_event_list = self._selector.poll(timeout)
416 except InterruptedError:
417 return ready
ipdb>
Notcurses-info seems to work:
~ 9m 18s contour !8/196
❯ notcurses-info
notcurses 3.0.6 on Contour 0.3.13-master-c50b38ec (Linux 5.15.0-79-generic)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.