0
我在网格上创建了一个包含多个子图的图。这些图在两个参数上有所不同,所以我希望它看起来像是在一个坐标系中下的。直接在matplotlib图上绘制箭头
我设法在图上直接使用subplot旁边的matplotlib.lines.Line2D()来绘制线条。 但我宁愿有一个箭头,而不是一条线,使其更清晰。 (我可以用fig.text添加特定的参数值()。)
I'd like the blue lines to be arrows
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from itertools import product
fig = plt.figure()
plotGrid = mpl.gridspec.GridSpec(2, 2)
x = np.linspace(0,10,10000)
y = [j* np.sin(x + i) for i,j in product(range(2), range(1,3))]
for i in range(4):
ax = plt.Subplot(fig, plotGrid[i])
for sp in ax.spines.values():
sp.set_visible(False)
ax.plot(x,y[i], color = 'r')
ax.set_xticks([])
ax.set_yticks([])
fig.add_subplot(ax)
all_axes = fig.get_axes()
#I would like these lines to be arrows
blcorPosn = 0.08 #bottom corner position
l1 = mpl.lines.Line2D([blcorPosn,blcorPosn], [1, blcorPosn],
transform=fig.transFigure, fig)
l2 = mpl.lines.Line2D([blcorPosn, 1], [blcorPosn, blcorPosn],
transform=fig.transFigure, fig)
fig.lines.extend([l1, l2])
我不知道这是否是要走的路。但是现在我花了一天的时间在这上面,我目前看到的绘制箭的唯一方法是直接在轴上绘制它们,但对我而言,这并不是我所能想象的。
这也是我在这里的第一篇文章,所以如何提问的建议是高度赞赏。 谢谢
http://matplotlib.org/examples/pylab_examples/arrow_simple_demo.html –
另一件事,也许,只是也许会帮助你: http://matplotlib.org/users/pyplot_tutorial.html #标注文本 – Drachenfels