A Textual widget wrapper for the Plotext plotting library
Low maintenance activity. Last release over 2 years ago, commits in 0 of the last 26 weeks. Weaker on commit activity and recent releases.
pip install textual-plotexttextual-plotext

A Textual widget wrapper for the Plotext plotting library.
Introduction
The library makes one widget available: PlotextPlot. This widget provides
a plt property, which should be used where you would normally use plt as
seen in the Plotext documentation.
Let's take the first example from the Plotext README:
import plotext as plt
y = plt.sin() # sinusoidal test signal
plt.scatter(y)
plt.title("Scatter Plot") # to apply a title
plt.show() # to finally plot
The Textual equivalent of this (including everything needed to make this a fully-working Textual application) is:
from textual.app import App, ComposeResult
from textual_plotext import PlotextPlot
class ScatterApp(App[None]):
def compose(self) -> ComposeResult:
yield PlotextPlot()
def on_mount(self) -> None:
plt = self.query_one(PlotextPlot).plt
y = plt.sin() # sinusoidal test signal
plt.scatter(y)
plt.title("Scatter Plot") # to apply a title
if __name__ == "__main__":
ScatterApp().run()
The main differences to note are:
- We're not directly importing
plotext. - We use
PlotextPlot.pltrather thanplt. - We don't call Plotext's
showmethod,PlotextPlottakes care of this.
Installation
The library can be installed from PyPi:
$ pip install textual-plotext
Once installed you can quickly test the library by running the demo:
$ python -m textual_plotext
The demo app includes many of the examples shown in the Plotext README.
Longer example
For a longer example of how to use the PlotextPlot widget, take a look at
examples/textual_towers_weather.py.
As a bonus it also shows an example of using Textual's to create a to pull
the data from the backend.