pycharm uses the matplotlib.pyplot solution of not displaying graphics
- 2021-01-03 20:59:16
- OfStack
In the following case, the image can be saved normally, but plt. show() cannot display the image normally, here is to use the pandas module to read the csv file:
# coding=utf-8
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv('ccpoints.csv', header=0)
plt.scatter(data.x, data.y, c="red", marker='o', label='ccpoints')
plt.xlabel('x')
plt.ylabel('y')
plt.legend(loc=2)
plt.show()
plt.savefig("one.png")
Add two lines of code before the import module import ES9en. pyplot as plt
import matplotlib
matplotlib.use('TkAgg')
If set to:
import matplotlib
matplotlib.use('Agg')
Graphics will not be displayed, which you can do when you batch graphics.