Placing images on figures

Hi everybody,

I'd like to draw thumbnails of images on various plots, e.g., a bar
chart with a picture placed at the base of the bar, or a scatter plot
with photos next to select points.

Reading and resizing the image aren't an issue. However, I've been
searching all day, and I can't figure out how to call imshow without
it taking over the axis in which its drawn.

Thanks,
Eamon

You could try using separate axes for your images, as in
http://matplotlib.sourceforge.net/examples/pylab_examples/axes_demo.html

Cheers,
Scott

···

On 10 June 2010 07:21, Eamon Caddigan <eamon.caddigan@...287...> wrote:
I'd like to draw thumbnails of images on various plots, e.g., a bar
chart with a picture placed at the base of the bar, or a scatter plot
with photos next to select points.

Reading and resizing the image aren't an issue. However, I've been
searching all day, and I can't figure out how to call imshow without
it taking over the axis in which its drawn.

Thanks Scott. In order to precisely position an image using separate
axes, I'd need to be able to query and set the margin between the
bounding box and the actual axes. I can't seem to find any way to do
that, either.

···

On Thu, Jun 10, 2010 at 1:13 AM, Scott Sinclair <scott.sinclair.za@...287...> wrote:

On 10 June 2010 07:21, Eamon Caddigan <eamon.caddigan@...287...> wrote:
I'd like to draw thumbnails of images on various plots, e.g., a bar
chart with a picture placed at the base of the bar, or a scatter plot
with photos next to select points.

Reading and resizing the image aren't an issue. However, I've been
searching all day, and I can't figure out how to call imshow without
it taking over the axis in which its drawn.

You could try using separate axes for your images, as in
http://matplotlib.sourceforge.net/examples/pylab_examples/axes_demo.html

Cheers,
Scott

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Actually, since axes are created with normalized coordinates, what I
really need is a way to query the size of the current figure, in
pixels.

···

On Thu, Jun 10, 2010 at 7:43 AM, Eamon Caddigan <eamon.caddigan@...287...> wrote:

Thanks Scott. In order to precisely position an image using separate
axes, I'd need to be able to query and set the margin between the
bounding box and the actual axes. I can't seem to find any way to do
that, either.

On Thu, Jun 10, 2010 at 1:13 AM, Scott Sinclair > <scott.sinclair.za@...287...> wrote:

On 10 June 2010 07:21, Eamon Caddigan <eamon.caddigan@...287...> wrote:
I'd like to draw thumbnails of images on various plots, e.g., a bar
chart with a picture placed at the base of the bar, or a scatter plot
with photos next to select points.

Reading and resizing the image aren't an issue. However, I've been
searching all day, and I can't figure out how to call imshow without
it taking over the axis in which its drawn.

You could try using separate axes for your images, as in
http://matplotlib.sourceforge.net/examples/pylab_examples/axes_demo.html

Cheers,
Scott

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Actually, You might want to check out axes_grid module in the mpl_toolkits. After a quick perusal, I think InsetLocator might be what you are looking for in the axes_grid module.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html

I hope this helps,
Ben Root

···

On Thu, Jun 10, 2010 at 8:54 AM, Eamon Caddigan <eamon.caddigan@…287…> wrote:

Actually, since axes are created with normalized coordinates, what I

really need is a way to query the size of the current figure, in

pixels.

On Thu, Jun 10, 2010 at 7:43 AM, Eamon Caddigan > <eamon.caddigan@…287…> wrote:

Thanks Scott. In order to precisely position an image using separate

axes, I’d need to be able to query and set the margin between the

bounding box and the actual axes. I can’t seem to find any way to do

that, either.

On Thu, Jun 10, 2010 at 1:13 AM, Scott Sinclair > > > <scott.sinclair.za@gmail.com> wrote:

On 10 June 2010 07:21, Eamon Caddigan <eamon.caddigan@…287…> wrote:

I’d like to draw thumbnails of images on various plots, e.g., a bar

chart with a picture placed at the base of the bar, or a scatter plot

with photos next to select points.

Reading and resizing the image aren’t an issue. However, I’ve been

searching all day, and I can’t figure out how to call imshow without

it taking over the axis in which its drawn.

You could try using separate axes for your images, as in

http://matplotlib.sourceforge.net/examples/pylab_examples/axes_demo.html

Cheers,

Scott


ThinkGeek and WIRED’s GeekDad team up for the Ultimate

GeekDad Father’s Day Giveaway. ONE MASSIVE PRIZE to the

lucky parental unit. See the prize list and enter to win:

http://p.sf.net/sfu/thinkgeek-promo


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


ThinkGeek and WIRED’s GeekDad team up for the Ultimate

GeekDad Father’s Day Giveaway. ONE MASSIVE PRIZE to the

lucky parental unit. See the prize list and enter to win:

http://p.sf.net/sfu/thinkgeek-promo


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Can you describe why using the "extent" keyword does not serve your purpose?

The svn version of matplotlib support BboxImage which might be better
(depending on your use case).

-JJ

···

On Thu, Jun 10, 2010 at 1:21 AM, Eamon Caddigan <eamon.caddigan@...287...> wrote:

Hi everybody,

I'd like to draw thumbnails of images on various plots, e.g., a bar
chart with a picture placed at the base of the bar, or a scatter plot
with photos next to select points.

Reading and resizing the image aren't an issue. However, I've been
searching all day, and I can't figure out how to call imshow without
it taking over the axis in which its drawn.

Thanks,
Eamon

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks for the suggestion!

The reason my initial attempts failed was because I (erroneously)
assumed that the default axis spanned (0, 0), (1, 1). Now I that I
know better, I can place an axis for each image in the right place and
everything looks fine.

However, I'm still interested in knowing how to query the pixel size
of the figure, so I can translate normalized axis coordinates to pixel
coordinates.

-Eamon

···

On Thu, Jun 10, 2010 at 9:40 AM, Benjamin Root <ben.root@...1304...> wrote:

Actually, You might want to check out axes_grid module in the mpl_toolkits.
After a quick perusal, I think InsetLocator might be what you are looking
for in the axes_grid module.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html

I hope this helps,
Ben Root

On Thu, Jun 10, 2010 at 8:54 AM, Eamon Caddigan <eamon.caddigan@...287...> > wrote:

Actually, since axes are created with normalized coordinates, what I
really need is a way to query the size of the current figure, in
pixels.

On Thu, Jun 10, 2010 at 7:43 AM, Eamon Caddigan >> <eamon.caddigan@...287...> wrote:
> Thanks Scott. In order to precisely position an image using separate
> axes, I'd need to be able to query and set the margin between the
> bounding box and the actual axes. I can't seem to find any way to do
> that, either.
>
> On Thu, Jun 10, 2010 at 1:13 AM, Scott Sinclair >> > <scott.sinclair.za@...287...> wrote:
>>>On 10 June 2010 07:21, Eamon Caddigan <eamon.caddigan@...287...> wrote:
>>> I'd like to draw thumbnails of images on various plots, e.g., a bar
>>> chart with a picture placed at the base of the bar, or a scatter plot
>>> with photos next to select points.
>>>
>>> Reading and resizing the image aren't an issue. However, I've been
>>> searching all day, and I can't figure out how to call imshow without
>>> it taking over the axis in which its drawn.
>>
>> You could try using separate axes for your images, as in
>>
>> http://matplotlib.sourceforge.net/examples/pylab_examples/axes_demo.html
>>
>> Cheers,
>> Scott
>>

Hi,

Eamon Caddigan <eamon.caddigan@...287...>

The reason my initial attempts failed was because I (erroneously)
assumed that the default axis spanned (0, 0), (1, 1). Now I that I
know better, I can place an axis for each image in the right place and
everything looks fine.

However, I'm still interested in knowing how to query the pixel size
of the figure, so I can translate normalized axis coordinates to pixel
coordinates.

http://matplotlib.sourceforge.net/users/transforms_tutorial.html

Maybe something along the lines
ax.transAxes.transform((0, 0)) - ax.transAxes.transform((1, 1))
?

transAxes.transform() was exactly what I was looking for. Thanks!

-Eamon

···

On Wed, Jun 16, 2010 at 4:06 PM, Malte Dik <malte.dik@...273...> wrote:

Hi,

Eamon Caddigan <eamon.caddigan@...287...>

The reason my initial attempts failed was because I (erroneously)
assumed that the default axis spanned (0, 0), (1, 1). Now I that I
know better, I can place an axis for each image in the right place and
everything looks fine.

However, I'm still interested in knowing how to query the pixel size
of the figure, so I can translate normalized axis coordinates to pixel
coordinates.

http://matplotlib.sourceforge.net/users/transforms_tutorial.html

Maybe something along the lines
ax.transAxes.transform((0, 0)) - ax.transAxes.transform((1, 1))