import numpy as np
import matplotlib.pyplot as plt
# 不用打imshow也能显示
%matplotlib inline
风格
plt.style.available
['bmh',
'classic',
'dark_background',
'fast',
'fivethirtyeight',
'ggplot',
'grayscale',
'seaborn-bright',
'seaborn-colorblind',
'seaborn-dark-palette',
'seaborn-dark',
'seaborn-darkgrid',
'seaborn-deep',
'seaborn-muted',
'seaborn-notebook',
'seaborn-paper',
'seaborn-pastel',
'seaborn-poster',
'seaborn-talk',
'seaborn-ticks',
'seaborn-white',
'seaborn-whitegrid',
'seaborn',
'Solarize_Light2',
'tableau-colorblind10',
'_classic_test']
# 线型,颜色,线条宽度,marker是标志点,alpha是透明度,可以自己找
plt.plot([1,2,3],[1,2,3],linestyle='--',color='r',linewidth=3.0,marker='o',markerfacecolor='b',markersize=10,alpha=.5)
plt.xlabel('x', fontsize=14) # 字体大小
plt.ylabel('y')
plt.title('test')
plt.text(2,2.2,'point')
# 显示网格,比较方便加注释
plt.grid(True)
# 添加注释,xy是箭头指向的位置,xytext是标注的位置,后面是箭头属性,shrink调整箭头的放缩,与注释的相对位置
plt.annotate('point',xy=(2,2),xytext=(2.5,1.5),arrowprops=dict(
facecolor='black',shrink=0.05,headwidth=16,headlength=20))
Text(2.5,1.5,'point')
plt.style.use('ggplot')
plt.plot([1,2,3],[1,2,3])
[]
plt.style.use(['ggplot','bmh'])
plt.plot([1,2,3],[1,2,3])
[]
plt.xkcd()
plt.plot([1,2,3],[1,2,3])
[]