Program change (6) python sin drawing https://qiita.com/kaizen_nagoya/items/2702bdf0b89b3d841921 On docker for docker (89) python2, python3 with docker https://qiita.com/kaizen_nagoya/items/ecbe11a4d743357134d5 Start from docker made in Take errors and execute
# python3 sin3d.py
# ls
sin3d.py sin3.png
When I thought that sin3.png was successfully created, the file was pure white.
My head turned white.
If you read the code carefully,
sin3.py
#! /usr/bin/env python
#codeing:utf-8
# https://qiita.com/KntKnk0328/items/5ef40d9e77308dd0d0a4
# https://qiita.com/kaizen_nagoya/items/2702bdf0b89b3d841921
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
#Data generation
x = np.linspace(0, 10, 100)
y = np.sin(x)
#Plot area(Figure, Axes)Initialization of
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(133)
#Creating a bar chart
ax.scatter( x, y)
#Insert horizontal and vertical lines
ax.axvline(0)
fig = plt.figure()
#plt.show()
fig.savefig('sin3.png')
The plt.figure added on the third line from the end is running higher I guess it's supposed to be erased after drawing.
Comment out the relevant line and execute.
I drew the contents of the file.
Recommended Posts