From: Tony Yu <ts...@gm...> - 2012-03-12 18:28:41
|
On Sun, Mar 11, 2012 at 2:13 PM, Tony Yu <ts...@gm...> wrote: > Is it possible to draw an arrow with a dashed line? > > I tried using a fancy arrow patch and set the linestyle: > > #~~~ > import matplotlib.pyplot as plt > > fix, ax = plt.subplots() > ax.set_xlim((-1,5)) > ax.set_ylim((-5,3)) > > ax.annotate('simple', xy=(2., -1), xycoords='data', > xytext=(100, 60), textcoords='offset points', > size=20, > arrowprops=dict(arrowstyle="simple", > fc="0.6", ec="none", linestyle='dashed', > connectionstyle="arc3,rad=0.3"), > ) > plt.show() > #~~~ > > But the linestyle argument just gets ignored. > > Is there a way to grab the connection path object and then change that to > a dashed line? Actually, I'm not even sure it's possible to set a linestyle > for a Path (since dashed lines are normally Line2D). Suggestions? > > Thanks, > -Tony > Nevermind: I though arrowstyle='simple' and arrowstyle='-|>' were the same thing, but apparently not (I guess one draws the line as a patch, and the other as a line). So the following works as expected: #~~~~ import matplotlib.pyplot as plt fix, ax = plt.subplots() ax.set_xlim((-1,5)) ax.set_ylim((-5,3)) ax.annotate('simple', xy=(2., -1), xycoords='data', xytext=(100, 60), textcoords='offset points', size=20, arrowprops=dict(arrowstyle="-|>", fc="k", ec="k", linestyle='dashed', connectionstyle="arc3,rad=0.3"), ) plt.show() #~~~ |