Gabriel
Gabriel

Reputation: 42329

matplotlib parameter 'edgecolor' does not work with quiver?

The matplotlib.axes.Axes.quiver docs state that:

Arrow outline

linewidths and edgecolors can be used to customize the arrow outlines

However, a simple test code shows that edgecolor apparently does nothing. Am I missing something?

import matplotlib.pyplot as plt
import numpy as np

X = np.arange(-3, 3, 1)
Y = np.arange(-3, 3, 1)
U, V = np.meshgrid(X, Y)

plt.quiver(X, Y, U, V, edgecolor='r')
plt.show()

enter image description here

Upvotes: 3

Views: 1462

Answers (1)

dm2
dm2

Reputation: 4275

It seems linewidth parameter is set to 0 as default for plt.quiver. Adding some sort of value in the function call starts displaying the edges of arrows. I.e.:

import matplotlib.pyplot as plt
import numpy as np

X = np.arange(-3, 3, 1)
Y = np.arange(-3, 3, 1)
U, V = np.meshgrid(X, Y)

plt.quiver(X, Y, U, V, edgecolor='r', linewidth = 1)
plt.show()

Output:

enter image description here

Upvotes: 5

Related Questions