question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Idea: Matplotlib Backend Mode

See original GitHub issue

Hi! I found this library and it’s very interesting. Thanks for the great library.

One immediate thought I have is that its programmatic interface is quite independent. I wish I would be able to use the same matplotlib code for drawing plots, so implementing a matplotlib backend or (some sort of wrapper) would be great.

The API showcased in https://github.com/piccolomo/plotext/blob/master/readme/subplots.md follows the legacy plt. matplotlib API, which I think is bad and should be discouraged.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
piccolomocommented, Jun 12, 2022

Hi @wookayin,

I have worked on your request and added the function from_matplotlib() function, in the new version 5.1, available only on GitHub for now, using:

pip install git+https://github.com/piccolomo/plotext

The function is described here and you have been credited here.

Any feedback or double test is appreciated 😃.

Thanks and all the best, Savino

1reaction
wookayincommented, Feb 12, 2022

I looked a bit into how this could be realized, and a tentative conclusion is due to much design differences this would not be easily possible.

The matplotlib backend API requires implementation of figure manager (which is straightforward) and renderer. The renderer is supposed to draw graphics being rendered from matplotlib-internal data structures (such as Figure, SubplotAxes). Mostly the renderer would need to implement how to draw path, image, and text, but the current implementation of plotext has nothing to do with matplotlib internal APIs and has their own replication of similar concepts. So writing an adapter or bridge is not straightforward (unless a huge refactoring and modularization happens); this library is designed to do simple plotting jobs based on its own interface and internal data structures (seemingly similar but different a lot), and the core implementation of TUI drawing is strongly coupled with those APIs which are not compatible with matplotlib.

I will close this issue for now, but if you have any other thoughts I’d be happy to discuss more.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Backends — Matplotlib 3.6.2 documentation
Without a backend explicitly set, Matplotlib automatically detects a usable backend based on what is available on your system and on whether a...
Read more >
Matplotlib doesn't show plots in new window
Hi All, Setup: Ubuntu 18.04, Pycharm 2019.2 pro, python 3.6.8, ... You can try different matplotlib backends (backends are switched in the ...
Read more >
Matplotlib is currently using agg, which is a non-GUI backend ...
Solution 1: is to install the GUI backend tk. I found a solution to my problem (thanks to the help of ImportanceOfBeingErnest).
Read more >
Matplotlib: Interactive and Non-Interactive Use
matplotlib has the concept of backends — essentially the target canvas or surface it can render a figure to. A backend implementation takes ......
Read more >
Using matplotlib in a python shell - omz:software
ipython also turns on interactive mode for you, which causes every pyplot command to trigger a figure update, and also provides a matplotlib...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found