X Tutup
Skip to content

potential bug with plt.arrow and plt.annotate when setting linestyle via tuples #7623

@ebauch

Description

@ebauch

Seems like you cannot set the linestyle for arrows via tuples. This just works fine

plt.annotate("",
xy=(0, 0), xycoords='data', xytext=(1, 1), textcoords='data',
arrowprops=dict(arrowstyle="->", connectionstyle="arc3", color='0.5', ls='--')
)

where the bold part sets the linestyle of the arrow. However, this won't work and throws an error when using the tuple description of linestyle:

plt.annotate("",
xy=(0, 0), xycoords='data', xytext=(1, 1), textcoords='data',
arrowprops=dict(arrowstyle="->", connectionstyle="arc3", color='0.5', ls=(0, [2 ,2]))
)

The error says

TypeError: unhashable type: 'list'

The same is true for plt.arrow. The tuple description works just fine on regular plots:

xx = np.linspace(0, 1, 100)
plt.plot(xx, xx, ls=(0, [2, 2]))

Am I doing something wrong or is this an actual bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup