接下来,开始记录使用matplotlib这个号称python使用最广泛的图形库,所遇到的种种神坑。
一、 画节点图:
1. 画节点和箭头
查阅api文档,觉得annotate类封装的不错。
import matplotlib.pyplot as plt
from matplotlib.text import OffsetFrom
bbox_args = dict(boxstyle="round", fc="0.8")
arrow_args = dict(arrowstyle="->")
an1 = plt.annotate('Drag me 1', xy=(.5, .7), xycoords='data',
# xytext=(.5, .7), textcoords='data',
ha="center", va="center",
bbox=bbox_args,
# arrowprops=arrow_args
)
an2 = plt.annotate('Drag me 2', xy=(.5, .5), xycoords=an1,
xytext=(.5, .3), textcoords='axes fraction',
va="center", ha="left",
bbox=bbox_args,
arrowprops=dict(patchB=an1.get_bbox_patch(),
connectionstyle=