ipymd.plotting package

Submodules

ipymd.plotting.plotter module

Created on Fri Jul 1 16:45:06 2016

@author: cjs14

class ipymd.plotting.plotter.Plotter(nrows=1, ncols=1, figsize=(5, 4))[source]

Bases: object

a class to deal with data plotting

figure

matplotlib.figure

the figure

axes

list or single matplotlib.axes

if more than one then returns a list (ordered in reading direction), else returns one instance

add_image(image, axes=0, interpolation='bicubic', hide_axes=True, width=1.0, height=1.0, origin=(0.0, 0.0), **kwargs)[source]

add image to axes

add_image_annotation(img, xy=(0, 0), arrow_xy=None, axes=0, zoom=1, xytype='axes points', arrow_xytype='data', arrowprops={'connectionstyle': 'arc3, rad=0.2', 'alpha': 0.4, 'arrowstyle': 'simple', 'facecolor': 'black'})[source]

add an image to the plot

coordtype:

argument coordinate system
‘figure points’ points from the lower left corner of the figure
‘figure pixels’ pixels from the lower left corner of the figure
‘figure fraction’ 0,0 is lower left of figure and 1,1 is upper right
‘axes points’ points from lower left corner of axes
‘axes pixels’ pixels from lower left corner of axes
‘axes fraction’ 0,0 is lower left of axes and 1,1 is upper right
‘data’ use the axes data coordinate system

for arrowprops see http://matplotlib.org/users/annotations_guide.html#annotating-with-arrow

axes
display_plot(tight_layout=False)[source]

display plot in IPython

if tight_layout is True it may crop anything outside axes

figure
get_image(size=300, dpi=300, tight_layout=False)[source]

return as PIL image

if tight_layout is True it may crop anything outside axes

resize_axes(width=0.8, height=0.8, left=0.1, bottom=0.1, axes=0)[source]

resiaze axes, for instance to fit object outside of it

ipymd.plotting.plotter.animation_contourf(x_iter, y_iter, z_iter, interval=20, xlim=(0, 1), ylim=(0, 1), zlim=(0, 1.0), cmap='viridis', cbar=True, incl_controls=True, plot=None, ax=0, **plot_kwargs)[source]

create an animation of multiple x,y data sets

x_iter : iterable
any iterable of x data sets, e.g. [[1,2,3],[4,5,6]]
y_iter : iterable
an iterable of y data sets, e.g. [[1,2,3],[4,5,6]]
y_iter : iterable
an iterable of z(x,y) data sets, each set must be of shape (len(x), len(y))
interval : int
draws a new frame every interval milliseconds
xlim : tuple
the x_limits for the axes (ignored if using existing plotter)
ylim : tuple
the y_limits for the axes (ignored if using existing plotter)
zlim : tuple
the z_limits for the colormap
cmap : str or matplotlib.cm
the colormap to use (see http://matplotlib.org/examples/color/colormaps_reference.html)
incl_controls : bool
include Javascript play controls
plot : ipymd.plotting.Plotter
an existing plotter object
ax : int
the id number of the axes on which to plot (if using existing plotter)
plot_kwargs : various
key word arguments to pass to plot method, e.g. marker=’o’, color=’b’, ...
Returns:html – a html object
Return type:IPython.core.display.HTML

Notes

x_iter and y_iter can be yield functions such as:

def y_iter(x_iter):
    for xs in x_iter:
        yield [i**2 for i in xs]

This means that the values do not have to be necessarily pre-computed.

ipymd.plotting.plotter.animation_line(x_iter, y_iter, interval=20, xlim=(0, 1), ylim=(0, 1), incl_controls=True, plot=None, ax=0, **plot_kwargs)[source]

create an animation of multiple x,y data sets

x_iter : iterable
any iterable of x data sets, e.g. [[1,2,3],[4,5,6]]
y_iter : iterable
an iterable of y data sets, e.g. [[1,2,3],[4,5,6]]
interval : int
draws a new frame every interval milliseconds
xlim : tuple
the x_limits for the axes (ignored if using existing plotter)
ylim : tuple
the y_limits for the axes (ignored if using existing plotter)
incl_controls : bool
include Javascript play controls
plot : ipymd.plotting.Plotter
an existing plotter object
ax : int
the id number of the axes on which to plot (if using existing plotter)
plot_kwargs : various
key word arguments to pass to plot method, e.g. marker=’o’, color=’b’, ...
Returns:html – a html object
Return type:IPython.core.display.HTML

Notes

x_iter and y_iter can be yield functions such as:

def y_iter(x_iter):
    for xs in x_iter:
        yield [i**2 for i in xs]

This means that the values do not have to be necessarily pre-computed.

ipymd.plotting.plotter.animation_scatter(x_iter, y_iter, interval=20, xlim=(0, 1), ylim=(0, 1), incl_controls=True, plot=None, ax=0, **plot_kwargs)[source]

create an animation of multiple x,y data sets

x_iter : iterable
any iterable of x data sets, e.g. [[1,2,3],[4,5,6]]
y_iter : iterable
an iterable of y data sets, e.g. [[1,2,3],[4,5,6]]
interval : int
draws a new frame every interval milliseconds
xlim : tuple
the x_limits for the axes (ignored if using existing plotter)
ylim : tuple
the y_limits for the axes (ignored if using existing plotter)
incl_controls : bool
include Javascript play controls
plot : ipymd.plotting.Plotter
an existing plotter object
ax : int
the id number of the axes on which to plot (if using existing plotter)
plot_kwargs : various
key word arguments to pass to plot method, e.g. marker=’o’, color=’b’, ...
Returns:html – a html object
Return type:IPython.core.display.HTML

Notes

x_iter and y_iter can be yield functions such as:

def y_iter(x_iter):
    for xs in x_iter:
        yield [i**2 for i in xs]

This means that the values do not have to be necessarily pre-computed.

ipymd.plotting.plotter.style(style)[source]

A context manager to apply matplotlib style settings from a style specification.

Popular styles include; default, ggplot, xkcd, and are used in the the following manner:

with ipymd.plotting.style('default'):
    plot = ipymd.plotting.Plotter()
    plot.display_plot()
Parameters:style (str, dict, or list) –

A style specification. Valid options are:

str The name of a style or a path/URL to a style file. For a list of available style names, see style.available.
dict Dictionary with valid key/value pairs for matplotlib.rcParams.
list A list of style specifiers (str or dict) applied from first to last in the list.

Module contents