简单的图轴自定义
自定义简单绘图的背景,标签和刻度。
1
| import matplotlib.pyplot as plt
|
用 plt.figure 创建一个 matplotlib.figure.Figure 实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| fig = plt.figure() rect = fig.patch rect.set_facecolor('lightgoldenrodyellow')
ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4]) rect = ax1.patch rect.set_facecolor('lightslategray')
for label in ax1.xaxis.get_ticklabels(): label.set_color('red') label.set_rotation(45) label.set_fontsize(16)
for line in ax1.yaxis.get_ticklines(): line.set_color('green') line.set_markersize(25) line.set_markeredgewidth(3)
plt.show()
|

参考
此示例中显示了以下函数,方法,类和模块的使用:
1 2 3 4 5 6 7 8 9 10 11
| import matplotlib matplotlib.axis.Axis.get_ticklabels matplotlib.axis.Axis.get_ticklines matplotlib.text.Text.set_rotation matplotlib.text.Text.set_fontsize matplotlib.text.Text.set_color matplotlib.lines.Line2D matplotlib.lines.Line2D.set_color matplotlib.lines.Line2D.set_markersize matplotlib.lines.Line2D.set_markeredgewidth matplotlib.patches.Patch.set_facecolor
|
下载这个示例