# -*- coding:utf-8 -*- import matplotlib.pyplot as plt plt.style.use('ggplot') from matplotlib.font_manager import * import numpy as np import pandas as pd #定义自定义字体 myfont = FontProperties(fname='/temp/msyh.ttf') #解决负号'-'显示为方块的问题 plt.rcParams['axes.unicode_minus']=False df = pd.read_csv('/temp/iris.data',names=['花萼长度', '花萼宽度', '花瓣长度', '花瓣宽度', '类别']) fig,ax = plt.subplots(figsize=(6,6)) ax.scatter(df['花萼长度'],df['花萼宽度'], color='green') ax.set_xlabel(u'花萼长度',fontproperties=myfont) ax.set_ylabel(u'花萼宽度',fontproperties=myfont) ax.set_title(u'花萼散点图',fontproperties=myfont) plt.tight_layout() plt.show()