柱状图阴影
Python
hatches = ["/", "\\", "|", "-", "+", "x", "o", "O", ".", "*"] # * 表现为星星 bars = plt.bar(x, y, bar_width, hatch=...)
参考:https://matplotlib.org/stable/gallery/shapes_and_collections/hatch_style_reference.html
折线图填充
Python
plt.fill_between(x, y_bottom, y_top)
会在 y_bottom 到 y_top 之间填充颜色。
示例(紫色区域):

柱状图标注数值
Python
from matplotlib.axes import Axes def add_num_annotation(ax: Axes, acc=2, rotation=0, margin_bottom=2, fontsize=18): for _p in ax.patches: if _p.get_height() == 0: continue ax.annotate( str(round(_p.get_height(), acc)) if acc != 0 else str(int(round(_p.get_height(), 0))), (_p.get_x() + _p.get_width() / 2.0, _p.get_height() * 1 + margin_bottom), ha="center", va="center", xytext=(0, 6), textcoords="offset points", rotation=rotation, fontsize=fontsize, )
Acknowledgement: Chengzhi Lu.