Skip to content

quiverkey.get_window_extent does not work #18530

Open
@dcherian

Description

@dcherian

Bug report

Bug summary

I'm trying to find the window extent of a quiverkey but cannot do so.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

u = np.ones((10, 10))
v = np.ones((10, 10))
x = np.arange(10)

q = plt.quiver(x, x, u, v)
key = plt.quiverkey(q, X=.9, Y=.6, U=0.5, label="quiv", coordinates="figure")

key.get_window_extent(plt.gcf().canvas.get_renderer())

Actual outcome

Bbox([[0.0, 0.0], [0.0, 0.0]])

image

Expected outcome

A BBox with non-zero values. Is there a workaround to find this with current matplotlib versions?

As background, I'm trying to make space for the quiverkey for this xarray PR: pydata/xarray#4407

We have code that makes space for a common legend using get_window_extent (e.g. https://xarray.pydata.org/en/stable/_images/ds_facet_scatter.png) and it would nice to have that "just work" with quiver keys

Matplotlib version

  • Operating system: Ubuntu 16.04

  • Matplotlib version: 3.2.0

  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline

  • Python version: 3.8

  • Jupyter version (if applicable):6.3

  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions