python Matplotlib给坐标轴标签添加文本框

import matplotlib.pyplot as plt
import numpy as np
x=["q","w","e","r","t","y"]#不变的依然是x表示标签值
y=[4,6,7,6,3,9]
plt.barh(x,y,align="center",color="green",alpha=0.6,label="barh")
box=dict(fc="red",pad=2,alpha=0.4)
#给坐标轴的标签加上文本框,就是使用bbox函数
plt.xlabel("xaxis",bbox=box)
plt.ylabel("ylabel",bbox=dict(fc="green",ec="black",pad=2,alpha=0.5))
plt.grid(True,color="red",ls="-.",axis="y")#axis表示值显示哪个轴的虚线
plt.legend()
plt.show()

 

posted @ 2019-08-23 09:41  朵朵奇fa  阅读(3638)  评论(0编辑  收藏  举报