2
1

More than 3 years have passed since last update.

メモ: terminal でグラフ描画 termplotlib

Last updated at Posted at 2020-09-29

インストール

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

pip install termplotlib

グラフ描画

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

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

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1