Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

get_window_extent method for an image object gives all zeros #2980

Copy link
Copy link
Closed
@breedlun

Description

@breedlun
Issue body actions

I am finding that the get_window_extent method for an image object gives all zeros.

For example

import numpy as np
import matplotlib.pyplot as plt

im = np.array([[0.25, 0.75, 1.0, 0.75], [0.1, 0.65, 0.5, 0.4], \
    [0.6, 0.3, 0.0, 0.2], [0.7, 0.9, 0.4, 0.6]])
fig = plt.figure()
ax = plt.subplot()
ax.set_xlim(0,1)
ax.set_ylim(0,1)
im_obj = ax.imshow(im, extent = [0.25, 0.75, 0.25, 0.75], interpolation = 'nearest')

produces the following plot

image

Now I want to get the image size in display coordinates, so I do the following:

fig.canvas.draw()
renderer = fig.canvas.renderer
im_bbox = im_obj.get_window_extent(renderer)

The trouble is print im_bbox produces Bbox('array([[ 0., 0.],\n [ 0., 0.]])'). The method .get_window_extent(renderer) works fine with text, lines, and patches, so I was a bit surprised to see it does not work with images.

In case it matters, I am using Matplotlib 1.3.0 with the TkAgg backend.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.