[PYTHON] Note: Graph drawing termplotlib on terminal

Installation

apt install -y \
    python3-scipy \
    python3-seaborn \
    python3-gnuplot \
    python3-pip

pip install termplotlib

Graph drawing

graph.py


import termplotlib as tpl
import numpy as np

x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x) + x
fig = tpl.figure()
fig.plot(x, y, width=60, height=20)
fig.show()

スクリーンショット_2020-09-29_11-43-09.png

Use csv

a.csv


1, 3
2, 1
3, 2.5
4, 8

graph.py


import pandas as pd
headers = ['x', 'y']
df = pd.read_csv('a.csv',names=headers)
#print(df)

import termplotlib as tpl
x = df['x']
y = df['y']
fig = tpl.figure()
fig.plot(x, y, width=60, height=20)
fig.show()

スクリーンショット_2020-09-29_12-16-41.png

Recommended Posts

Note: Graph drawing termplotlib on terminal
Graph drawing using matplotlib
Graph drawing in python
Until drawing a 3D graph in Python on windows10
Anaconda on Windows Terminal
Graph drawing method with matplotlib
Graph drawing with IPython Notebook