diff --git a/ultraplot/axes/plot.py b/ultraplot/axes/plot.py index 49b0687c4..dc7ff4f27 100644 --- a/ultraplot/axes/plot.py +++ b/ultraplot/axes/plot.py @@ -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 diff --git a/ultraplot/tests/test_plot.py b/ultraplot/tests/test_plot.py index e1662dd56..e3eb9455d 100644 --- a/ultraplot/tests/test_plot.py +++ b/ultraplot/tests/test_plot.py @@ -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