Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ultraplot/axes/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,9 @@ def curved_quiver(
density = _not_none(density, rc["curved_quiver.density"])
arrows_at_end = _not_none(arrow_at_end, rc["curved_quiver.arrows_at_end"])

if cmap:
cmap = constructor.Colormap(cmap)

solver = CurvedQuiverSolver(x, y, density)
if zorder is None:
zorder = mlines.Line2D.zorder
Expand Down
30 changes: 30 additions & 0 deletions ultraplot/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,3 +587,33 @@ def test_curved_quiver_multicolor_lines():
assert m.lines.get_array().size > 0 # we have colors set
assert m.lines.get_cmap() is not None
return fig


@pytest.mark.mpl_image_compare
@pytest.mark.parametrize(
"cmap",
(
"k", # color
"viridis", # built-in
"viko", # bundled with ultraplot
),
)
def test_curved_quiver_color_and_cmap(rng, cmap):
"""
Check that we can pass colors or colormaps
"""
x = np.linspace(0, 1, 5)
y = np.linspace(0, 1, 5)
X, Y = np.meshgrid(x, y)
U = np.ones_like(X)
V = np.ones_like(Y)

# Deal with color or cmap
color = rng.random(X.shape)
if cmap == "k":
cmap = None
color = "k"

fig, ax = uplt.subplots()
ax.curved_quiver(X, Y, U, V, color=color, cmap=cmap)
return fig