jktr / matplotlib-backend-kitty Goto Github PK
View Code? Open in Web Editor NEWshow matplotlib plots directly in your kitty terminal
License: Creative Commons Zero v1.0 Universal
show matplotlib plots directly in your kitty terminal
License: Creative Commons Zero v1.0 Universal
Hi, I was wondering if there is a way to control the size of the plot being shown on the terminal, since it always takes the whole terminal window no matter the figsize
Since I'm using conda I don't have a set PYTHONPATH
, can you help me out? I tried using conda develop and pointing to the repo, but despite it being added to the path.
Output of python -c "import sys; print(sys.path)"
['', '/home/joaogui/miniconda3/lib/python37.zip', '/home/joaogui/miniconda3/lib/python3.7', '/home/joaogui/miniconda3/lib/python3.7/lib-dynload', '/home/joaogui/miniconda3/lib/python3.7/site-packages', '/home/joaogui/Downloads/matplotlib-backend-kitty']
Due to complex nature of my Python projects that are often deployed in the cloud and involve external non-Python dependencies I usually prefer to isolate my environments using Docker rather than through Python's native mechanism of virtual environments.
The backend doesn't really work inside a Docker container. I tried to add kitty
as a dependency (which I'd try to avoid regardless) but it didn't really help.
Use kitty
's native protocol instead of kitty +kitten icat
to make it work both inside and outside Docker containers.
Hello. I'm having an issue where Matplotlib's facecolor options for the outside background is not working :
Situation 1 - should show white background if facecolor is not specified:
Situation 2 - should show the color specified on facecolor, but shows grey:
Situation 3 - Works normally without using MPL/Kitty backend:
I found on the code a reference to this:
Removing the , facecolor='#888888'
option makes it work just like normal matplotlib does:
No facecolor setting shows as white:
Specified color shows correctly:
I'm creating a PR for this change (see below).
My info:
fedora in ๐ server in ~
โฏ kitty -v
kitty 0.27.1 created by Kovid Goyal
fedora in ๐ server in ~
โฏ pip list | grep matplot
matplotlib 3.7.1
matplotlib-backend-kitty 2.1.2
fedora in ๐ server in ~
โฏ cat /etc/os-release
NAME="Fedora Linux"
VERSION="37 (Cloud Edition)"
ID=fedora
VERSION_ID=37
VERSION_CODENAME=""
PLATFORM_ID="platform:f37"
PRETTY_NAME="Fedora Linux 37 (Cloud Edition)"
...
fedora in ๐ server in ~
โฏ python -VVV
Python 3.11.2 (main, Feb 8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]
fedora in ๐ server in ~
โฏ
Hi,
I'm getting the following error trying to use the package: ValueError: invalid literal for int() with base 10: ''
Here is the full stack trace
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/plotting/_core.py", line 1758, in hexbin
return self(kind="hexbin", x=x, y=y, C=C, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/plotting/_core.py", line 917, in __call__
return plot_backend.plot(data, x=x, y=y, kind=kind, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/plotting/_matplotlib/__init__.py", line 72, in plot
plot_obj.draw()
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/pandas/plotting/_matplotlib/core.py", line 323, in draw
self.plt.draw_if_interactive()
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/matplotlib/pyplot.py", line 319, in draw_if_interactive
return _backend_mod.draw_if_interactive(*args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/matplotlib-backend-kitty/__init__.py", line 79, in draw_if_interactive
cls.show()
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/matplotlib-backend-kitty/__init__.py", line 83, in show
_Backend.show(*args, **kwargs)
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3524, in show
manager.show() # Emits a warning for non-interactive backend.
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.8/site-packages/matplotlib-backend-kitty/__init__.py", line 44, in show
px = list(map(int, px.split('x')))
ValueError: invalid literal for int() with base 10: ''
I am using Kitty 0.24.4 under MacOS 12.3 with Python 3.8.13 installed with Conda and Matplotlib 3.5.1
Would be nice to be able to pip install
this.
Firstly, thanks for the module, it has been hugely helpful for me on daily basis!
Secondly, calling plt.show()
with matplotlib==3.6.0
(specifically matplotlib-3.6.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
) release results in
UserWarning: Matplotlib is currently using module://matplotlib-backend-kitty, which is a non-GUI backend, so cannot show the figure.
_Backend.show(*args, **kwargs)
(same goes for matplotlib-backend-notcurses
, btw).
I am, unfortunately, at a loss, if I am simply missing something. Please let me know if I can help with more information.
I'm using python 3.11.1
with ipython 8.8.0
and got this error on trying to plot:
[ins] In [6]: plt.show()
/home/fbence/Codes/matplotlib-backend-kitty/__init__.py:83: UserWarning: Matplotlib is currently using module://matplotlib-backend-kitty, which is a non-GUI backend, so cannot show the figure.
_Backend.show(*args, **kwargs)
When playing around with Python, especially when plotting graphs is involved, I use ipython
most of the time.
The backend doesn't recognise ipython
as an interactive environment.
Pick a different heuristic that recognises ipython
, python -i
and simple python
in an interactive shell as interactive.
I cloned the repository to my current directory, opened python, ran the following -
import matplotlib
matplotlib.use('module://matplotlib-backend-kitty')
import matplotlib.pyplot as plt
import pandas; pandas.Series(range(10)).plot()
It shows only a grey picture. Solid grey.
then I tried
plt.show()
Nothing.
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.