From 6f5079a45abe939a4ae06f7cc9e2fba10a41774d Mon Sep 17 00:00:00 2001 From: marklescroart Date: Wed, 12 Feb 2025 16:52:36 -0800 Subject: [PATCH 1/2] Added quiver plot wrapper for matplotlib quiver w/ more sensible defaults than matplotlib has --- plot_utils/utils.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/plot_utils/utils.py b/plot_utils/utils.py index f895f5f..3ed3afa 100644 --- a/plot_utils/utils.py +++ b/plot_utils/utils.py @@ -624,7 +624,7 @@ def prep_inkscape_svg(h): f = h.get_figure() else: # type(h) is matplotlib.figure.Figure: A = h.get_axes() - f = h + f = hThe for ax in A: ToFix = [ax.title, ax.xaxis.label, ax.yaxis.label] + ax.get_xticklabels() + ax.get_yticklabels() + [t for t in ax.get_children() if isinstance(t, matplotlib.text.Text)] L = ax.get_legend() @@ -1675,3 +1675,35 @@ def colormap_2d( colored = (colored * 255).astype(np.uint8) colored = colored.reshape(data0.shape + (4,)) return colored + +def quiver(x, y, u, v, ax=None, cmap=None, + angles='xy', + scale_units='xy', + units='xy', + scale=0.5, + width=3, + headwidth=2.25, + headlength=3, + headaxislength=3, + **kwargs + ): + """Wrapper for matplotlib quiver function with more sensible defaults + + """ + if ax is None: + fig, ax = plt.subplots() + h_q = ax.quiver(x, y, u, v, + np.ones_like(dx)*1, + clim=(0, 1), + cmap=cmap, + angles=angles, + scale_units=scale_units, + units=units, + scale=scale, + width=width, + headwidth=headwidth, + headlength=headlength, + headaxislength=headaxislength, + **kwargs + ) + return h_q \ No newline at end of file From 538e7fb347a0054246b6b1d79f139db029a4f099 Mon Sep 17 00:00:00 2001 From: marklescroart Date: Wed, 12 Feb 2025 16:55:22 -0800 Subject: [PATCH 2/2] FIX: got rid of typo addition --- plot_utils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plot_utils/utils.py b/plot_utils/utils.py index 3ed3afa..6cb3efa 100644 --- a/plot_utils/utils.py +++ b/plot_utils/utils.py @@ -624,7 +624,7 @@ def prep_inkscape_svg(h): f = h.get_figure() else: # type(h) is matplotlib.figure.Figure: A = h.get_axes() - f = hThe + f = h for ax in A: ToFix = [ax.title, ax.xaxis.label, ax.yaxis.label] + ax.get_xticklabels() + ax.get_yticklabels() + [t for t in ax.get_children() if isinstance(t, matplotlib.text.Text)] L = ax.get_legend()