【lesson1】sin、cosを描く
import math
import matplotlib.pyplot as plt
import numpy as np
PI = math.radians(180) # Define PI
a = np.linspace(0, PI*2, int(PI*2/0.1))
b = []
c = []
for i in a:
b.append(math.cos(i))
c.append(math.sin(i))
plt.plot(c)
plt.plot(b)
plt.show()
File "e1.py", line 3, intkinterをインストールすれば解決できる。
import matplotlib.pyplot as plt
File "/home/lhw/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2371, in
switch_backend(rcParams["backend"])
File "/home/lhw/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 207, in switch_backend
backend_mod = importlib.import_module(backend_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/lhw/.local/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 1, in
from . import _backend_tk
File "/home/lhw/.local/lib/python3.6/site-packages/matplotlib/backends/_backend_tk.py", line 5, in
import tkinter as Tk
ModuleNotFoundError: No module named 'tkinter'
sudo apt-get install python3-tkmatplotlibの使い方:
※https://matplotlib.org/users/interactive.html
0 Comments:
Post a Comment
<< Home