- 支持中文
- 在Jupyter Notebook中显示清晰的图像
- 画图风格设置
- Marker和Linestyles属性设置
- 坐标轴属性设置
- 箭头标注
- Artist 类及集成关系图
- 官方推荐的参考资料
在图像中使用中文,需要输入代码:
plt.rcParams["font.sans-serif"] = ["SimHei"] plt.rcParams['axes.unicode_minus'] = False
可以根据自己的需要来调整中文的字体,详见中文字体的英文名称对照表
在Jupyter Notebook中显示清晰的图像
在Juputer Notebook中显示清晰的图像,输入
%matplotlib inline %config InlineBackend.figure_format = 'svg'
画图风格设置
使用 plt.style.use() 函数可以选择不同的画图风格,如
import matplotlib.pyplot as plt
plt.style.use('ggplot')
使用 plt.style.available 函数可查看所有内置的画图风格
import matplotlib.pyplot as plt plt.style.available
或者,查看官方的示例参考文档:Style sheets reference
Marker和Linestyles属性设置
-
数据点标记Marker属性:matplotlib.markers
-
线型Linestyles属性:Linestyles, Line2D.set_linestyle
坐标轴属性设置
- 所有支持的属性设置:matplotlib.axis
- 坐标轴刻度设置的示例:Rotating custom tick labels
箭头标注
在坐标轴中使用箭头标注
(1)ConnectionPatch函数
- ConnectionPatch函数:matplotlib.patches.ConnectionPatch
- 示例:Connect Simple01 Using ConnectionPatch Function
- ConnectionPatch支持的箭头属性设置:matplotlib.patches.ConnectionPatch
- 箭头形状设置:matplotlib.patches.ArrowStyle
(2)annotate函数
- annotate函数:matplotlib.axes.Axes.annotate
- 示例:Broken Barh; Creating a timeline with lines, dates, and text
- annotate函数中的text参数是不可缺少项,因此在不需要文字标注时不推荐使用annotate函数;
Artist 类及集成关系图
class matplotlib.artist.Artist
- Abstract base class for objects that render into a FigureCanvas
渲染为FigureCanvas的对象的抽象基类 - Typically, all visible elements in a figure are subclasses of Artist.
通常,figure中的所有可见元素都是Artist的子类。
Artist类的继承关系图:Inheritance Diagrams-matplotlib.artist
官方推荐的参考资料
官方推荐的参考资料:External resources
Ten Simple Rules for Better Figures
to be continued~



