Python与机器学习之数据可视化(四)

Matplotlib图像美化(例二)

在机器学习实际应用中,最关键的部分就是数据可视化,否则无论调试还是总结,你无从下手。python大牛们提供了非常牛逼的库—Matplotlib

回顾

  • Python与机器学习之数据可视化
  • Python与机器学习之数据可视化(二)
  • Python与机器学习之数据可视化(三)
  • 好文章

好,接下来直接举例

Show me the Picture

如图:
Python与机器学习之数据可视化(四)_第1张图片

Show me the Code

import matplotlib.pyplot as plt

fig = plt.figure()
#子图标题
fig.suptitle('bold figure suptitle', fontsize=14, fontweight='bold')

ax = fig.add_subplot(111)
fig.subplots_adjust(top=0.85)
ax.set_title('axes title')

#XY轴标签
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')

#注释文本
ax.text(3, 8, 'boxed italics text in data coords', style='italic',
        bbox={'facecolor': 'red', 'alpha': 0.5, 'pad': 10})

ax.text(2, 6, r'an equation: $E=mc^2$', fontsize=15)

ax.text(3, 2, u'unicode: Institut f\374r Festk\366rperphysik')

ax.text(0.95, 0.01, 'colored text in axes coords',
        verticalalignment='bottom', horizontalalignment='right',
        transform=ax.transAxes,
        color='green', fontsize=15)


ax.plot([2], [1], 'o')
#标记
ax.annotate('annotate', xy=(2, 1), xytext=(3, 4),
            arrowprops=dict(facecolor='black', shrink=0.05))

#轴修改
ax.axis([0, 10, 0, 10])

plt.show()

总结

这两个例子够读者复制使用了~

如果您看到这篇文章有收获或者有不同的意见,欢迎点赞或者评论。
python:190341254

你可能感兴趣的:(Python与数据分析)