spacepy_logo

Navigation

  • index
  • modules |
  • next |
  • previous |
  • homepage| 
  • development| 
  • search| 
  • documentation »
  • plot - Plot, various specialized plotting functions and associated utilities »
  • spacepy.plot.utils »
  • spacepy.plot.utils.add_logo

Logo

Previous topic

spacepy.plot.utils.EventClicker

Next topic

spacepy.plot.utils.annotate_xaxis

This Page

  • Show Source

Quick search

spacepy.plot.utils.add_logo¶

spacepy.plot.utils.add_logo(img, fig=None, pos='br', margin=0.05)[source]¶

Add an image (logo) to one corner of a plot.

The provided image will be placed in a corner of the plot and sized to maintain its aspect ratio and be as large as possible without overlapping any existing elements of the figure. Thus this should be the last call in constructing a figure.

Parameters
imgstr or numpy.ndarray

The image to place on the figure. If a string, assumed to be a filename to be read with imread(); if a numpy array, assumed to be the image itself (in a simliar format).

Returns
(axes, axesimg)tuple of Axes and AxesImage

The Axes object created to hold the iamge, and the AxesImage object for the image itself.

Other Parameters
figmatplotlib.figure.Figure

The figure on which to place the logo; if not specified, the gcf() function will be used.

posstr

The position to place the logo. br: bottom right; bl: bottom left; tl: top left; tr: top right

marginfloat

Margin to include on each side of figure, as a fraction of the larger dimension of the figure (width or height). Default is 0.05 (5%).

Notes

Calls draw() to ensure locations are up to date.

Examples

>>> import spacepy.plot.utils
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax0 = fig.add_subplot(211)
>>> ax0.plot([1, 2, 3], [1, 2, 1])
[<matplotlib.lines.Line2D at 0x00000000>]
>>> ax1 = fig.add_subplot(212)
>>> ax1.plot([1, 2, 3], [2, 1, 2])
[<matplotlib.lines.Line2D at 0x00000000>]
>>> spacepy.plot.utils.add_logo('logo.png', fig)
(<matplotlib.axes.Axes at 0x00000000>,
 <matplotlib.image.AxesImage at 0x00000000>)

Navigation

  • index
  • modules |
  • next |
  • previous |
  • homepage| 
  • development| 
  • search| 
  • documentation »
  • plot - Plot, various specialized plotting functions and associated utilities »
  • spacepy.plot.utils »
  • spacepy.plot.utils.add_logo
© Copyright 2011-2022, The SpacePy Team. Created using Sphinx 4.4.0.