Today's python error: image is blank

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. sin3.png

Recommended Posts

Today's python error: image is blank
Today's python error: killed
Today's python error: SyntaxError Non-ASCII character
[Python] Name Error: name'urlparse' is not defined
Today's python error: ModuleNotFoundError: No module named
Import error even though python is installed
Today's python error: ModuleNotFoundError: No module named'requests'
Today's python error: ModuleNotFoundError: No module named'bs4'
Python is easy
Python today's dog
Python Error Handling
What is python
Python is instance
What is Python
Today's python error: UnicodeEncodeError:'ascii' codec can't encode characters
What is wheezy in the Docker Python image?
Today's python error: UnicodeEncodeError:'utf-8' codec can't encode characters
Image URL is blank in GAE & GCS & Django
python int is infinite
[Python] What is Pipeline ...
Python Not Implemented Error
Today's python error: HTTPError: 404 Client Error: Not Found for url:
First Python image processing
Image format in Python
Today's python error: invalid keyword argument for this function
Python error list (Japanese)
Image processing with Python
[Python] What is virtualenv
[Python] for statement error
Weird Python error message ——Is that code really executed?
Grayscale image is displayed as a color image in OpenCV / Python
Image processing with Python (Part 2)
Python round is not strictly round
[Python] Debugging is more efficient!
How Python __dict__ is used
Image editing with python OpenCV
Python: 3D array image (numpy.array)
Sorting image files with Python (2)
[Python] SQLAlchemy error avoidance memorandum
Sorting image files with Python (3)
Python list is not a list
Image processing with Python (Part 1)
Tweet with image in Python
Sorting image files with Python
[youtube-dl] python3 SSL error (CERTIFICATE_VERIFY_FAILED)
[Python] Python and security-① What is Python?
Image processing with Python (Part 3)
Error when playing with python
#python Python Japanese syntax error avoidance
Python release cycle is faster!
Slice error in python (´ ; ω ; `)
Image processing by python (Pillow)
Image Processing Collection in Python
[Python] * args ** What is kwrgs?
Image data type conversion [Python]
Identity and equivalence Python is and ==
The image is a slug
What is a python map?
Error resolution python version check
[Python] Image processing with scikit-image
Python Basic Course (1 What is Python)