GPy.plotting.matplot_dep package

Submodules

GPy.plotting.matplot_dep.base_plots module

align_subplot_array(axes, xlim=None, ylim=None)[source]

Make all of the axes in the array hae the same limits, turn off unnecessary ticks use plt.subplots() to get an array of axes

align_subplots(N, M, xlim=None, ylim=None)[source]

make all of the subplots have the same limits, turn off unnecessary ticks

ax_default(fignum, ax)[source]
fewerXticks(ax=None, divideby=2)[source]
gperrors(x, mu, lower, upper, edgecol=None, ax=None, fignum=None, **kwargs)[source]
gpplot(x, mu, lower, upper, edgecol='#3300FF', fillcol='#33CCFF', ax=None, fignum=None, **kwargs)[source]
gradient_fill(x, percentiles, ax=None, fignum=None, **kwargs)[source]
meanplot(x, mu, color='#3300FF', ax=None, fignum=None, linewidth=2, **kw)[source]
removeRightTicks(ax=None)[source]
removeUpperTicks(ax=None)[source]
x_frame1D(X, plot_limits=None, resolution=None)[source]

Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits

x_frame2D(X, plot_limits=None, resolution=None)[source]

Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits

GPy.plotting.matplot_dep.defaults module

GPy.plotting.matplot_dep.img_plots module

The module contains the tools for ploting 2D image visualizations

plot_2D_images(figure, arr, symmetric=False, pad=None, zoom=None, mode=None, interpolation='nearest')[source]

GPy.plotting.matplot_dep.mapping_plots module

plot_mapping(self, plot_limits=None, which_data='all', which_parts='all', resolution=None, levels=20, samples=0, fignum=None, ax=None, fixed_inputs=[], linecol='#204a87')[source]
Plots the mapping associated with the model.
  • In one dimension, the function is plotted.
  • In two dimsensions, a contour-plot shows the function
  • In higher dimensions, we’ve not implemented this yet !TODO!

Can plot only part of the data and part of the posterior functions using which_data and which_functions

Parameters:
  • plot_limits (np.array) – The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
  • which_data ('all' or a slice object to slice self.X, self.Y) – which if the training data to plot (default all)
  • which_parts ('all', or list of bools) – which of the kernel functions to plot (additively)
  • resolution (int) – the number of intervals to sample the GP on. Defaults to 200 in 1D and 50 (a 50x50 grid) in 2D
  • levels (int) – number of levels to plot in a contour plot.
  • samples (int) – the number of a posteriori samples to plot
  • fignum (figure number) – figure to plot on.
  • ax (axes handle) – axes to plot on.
  • fixed_inputs (a list of tuples) – a list of tuple [(i,v), (i,v)...], specifying that input index i should be set to value v.
  • linecol – color of line to plot.
  • levels – for 2D plotting, the number of contour levels to use is ax is None, create a new figure

GPy.plotting.matplot_dep.maps module

apply_bbox(sf, ax)[source]

Use bbox as xlim and ylim in ax

bbox_match(sf, bbox, inside_only=True)[source]

Return the geometry and attributes of a shapefile that lie within (or intersect) a bounding box

Parameters:
  • sf (shapefile object) – shapefile
  • bbox (list of floats [x_min,y_min,x_max,y_max]) – bounding box
Inside_only:

True if the objects returned are those that lie within the bbox and False if the objects returned are any that intersect the bbox

new_shape_string(sf, name, regex, field=2, type=None)[source]
plot(shape_records, facecolor='w', edgecolor='k', linewidths=0.5, ax=None, xlims=None, ylims=None)[source]

Plot the geometry of a shapefile

Parameters:
  • shape_records (ShapeRecord object (output of a shapeRecords() method)) – geometry and attributes list
  • facecolor – color to be used to fill in polygons
  • edgecolor – color to be used for lines
  • ax (axes handle) – axes to plot on.
plot_bbox(sf, bbox, inside_only=True)[source]

Plot the geometry of a shapefile within a bbox

Parameters:
  • sf (shapefile object) – shapefile
  • bbox (list of floats [x_min,y_min,x_max,y_max]) – bounding box
Inside_only:

True if the objects returned are those that lie within the bbox and False if the objects returned are any that intersect the bbox

plot_string_match(sf, regex, field, **kwargs)[source]

Plot the geometry of a shapefile whose fields match a regular expression given

Parameters:sf (shapefile object) – shapefile
Regex:regular expression to match
Field:field number to be matched with the regex
string_match(sf, regex, field=2)[source]

Return the geometry and attributes of a shapefile whose fields match a regular expression given

Parameters:sf (shapefile object) – shapefile
Regex:regular expression to match
Field:field number to be matched with the regex

GPy.plotting.matplot_dep.plot_definitions module

class MatplotlibPlots[source]

Bases: GPy.plotting.abstract_plotting_library.AbstractPlottingLibrary

add_to_canvas(ax, plots, legend=False, title=None, **kwargs)[source]
annotation_heatmap(ax, X, annotation, extent=None, label=None, imshow_kwargs=None, **annotation_kwargs)[source]
annotation_heatmap_interact(ax, plot_function, extent, label=None, resolution=15, imshow_kwargs=None, **annotation_kwargs)[source]
barplot(ax, x, height, width=0.8, bottom=0, color='#3465a4', label=None, **kwargs)[source]
contour(ax, X, Y, C, levels=20, label=None, **kwargs)[source]
figure(rows=1, cols=1, gridspec_kwargs={}, tight_layout=True, **kwargs)[source]
fill_between(ax, X, lower, upper, color='#3465a4', label=None, **kwargs)[source]
fill_gradient(canvas, X, percentiles, color='#3465a4', label=None, **kwargs)[source]
imshow(ax, X, extent=None, label=None, vmin=None, vmax=None, **imshow_kwargs)[source]
imshow_interact(ax, plot_function, extent, label=None, resolution=None, vmin=None, vmax=None, **imshow_kwargs)[source]
new_canvas(figure=None, row=1, col=1, projection='2d', xlabel=None, ylabel=None, zlabel=None, title=None, xlim=None, ylim=None, zlim=None, **kwargs)[source]
plot(ax, X, Y, Z=None, color=None, label=None, **kwargs)[source]
plot_axis_lines(ax, X, color='#a40000', label=None, **kwargs)[source]
scatter(ax, X, Y, Z=None, color='#3465a4', label=None, marker='o', **kwargs)[source]
show_canvas(ax)[source]
surface(ax, X, Y, Z, color=None, label=None, **kwargs)[source]
xerrorbar(ax, X, Y, error, color='#a40000', label=None, **kwargs)[source]
yerrorbar(ax, X, Y, error, color='#a40000', label=None, **kwargs)[source]

GPy.plotting.matplot_dep.priors_plots module

plot(prior)[source]
univariate_plot(prior)[source]

GPy.plotting.matplot_dep.ssgplvm module

The module plotting results for SSGPLVM

class SSGPLVM_plot(model, imgsize)[source]

Bases: object

plot_inducing()[source]

GPy.plotting.matplot_dep.svig_plots module

plot(model, ax=None, fignum=None, Z_height=None, **kwargs)[source]
plot_traces(model)[source]

GPy.plotting.matplot_dep.util module

align_subplot_array(axes, xlim=None, ylim=None)[source]

Make all of the axes in the array hae the same limits, turn off unnecessary ticks use plt.subplots() to get an array of axes

align_subplots(N, M, xlim=None, ylim=None)[source]

make all of the subplots have the same limits, turn off unnecessary ticks

fewerXticks(ax=None, divideby=2)[source]
fixed_inputs(model, non_fixed_inputs, fix_routine='median', as_list=True, X_all=False)[source]

Convenience function for returning back fixed_inputs where the other inputs are fixed using fix_routine :param model: model :type model: Model :param non_fixed_inputs: dimensions of non fixed inputs :type non_fixed_inputs: list :param fix_routine: fixing routine to use, ‘mean’, ‘median’, ‘zero’ :type fix_routine: string :param as_list: if true, will return a list of tuples with (dimension, fixed_val) otherwise it will create the corresponding X matrix :type as_list: boolean

legend_ontop(ax, mode='expand', ncol=3, fontdict=None)[source]
removeRightTicks(ax=None)[source]
removeUpperTicks(ax=None)[source]

GPy.plotting.matplot_dep.variational_plots module

plot(parameterized, fignum=None, ax=None, colors=None, figsize=(12, 6))[source]

Plot latent space X in 1D:

  • if fig is given, create input_dim subplots in fig and plot in these
  • if ax is given plot input_dim 1D latent space plots of X into each axis
  • if neither fig nor ax is given create a figure with fignum and plot in there
colors:
colors of different latent space dimensions input_dim
plot_SpikeSlab(parameterized, fignum=None, ax=None, colors=None, side_by_side=True)[source]

Plot latent space X in 1D:

  • if fig is given, create input_dim subplots in fig and plot in these
  • if ax is given plot input_dim 1D latent space plots of X into each axis
  • if neither fig nor ax is given create a figure with fignum and plot in there
colors:
colors of different latent space dimensions input_dim

GPy.plotting.matplot_dep.visualize module

class data_show(vals)[source]

The data_show class is a base class which describes how to visualize a particular data set. For example, motion capture data can be plotted as a stick figure, or images are shown using imshow. This class enables latent to data visualizations for the GP-LVM.

close()[source]
modify(vals)[source]
class image_show(vals, axes=None, dimensions=(16, 16), transpose=False, order='C', invert=False, scale=False, palette=[], preset_mean=0.0, preset_std=1.0, select_image=0, cmap=None)[source]

Bases: GPy.plotting.matplot_dep.visualize.matplotlib_show

Show a data vector as an image. This visualizer rehapes the output vector and displays it as an image.

Parameters:
  • vals (axes handle) – the values of the output to display.
  • axes – the axes to show the output on.
  • dimensions (tuple) – the dimensions that the image needs to be transposed to for display.
  • transpose – whether to transpose the image before display.
  • order (string) – whether array is in Fortan ordering (‘F’) or Python ordering (‘C’). Default is python (‘C’).
  • invert (bool) – whether to invert the pixels or not (default False).
  • palette – a palette to use for the image.
  • preset_mean (double) – the preset mean of a scaled image.
  • preset_std (double) – the preset standard deviation of a scaled image.
  • cmap (matplotlib.cm) – the colormap for image visualization
modify(vals)[source]
set_image(vals)[source]
class lvm(vals, model, data_visualize, latent_axes=None, sense_axes=None, latent_index=[0, 1], disable_drag=False)[source]

Bases: GPy.plotting.matplot_dep.visualize.matplotlib_show

modify(vals)[source]

When latent values are modified update the latent representation and ulso update the output visualization.

on_click(event)[source]
on_enter(event)[source]
on_leave(event)[source]
on_move(event)[source]
show_sensitivities()[source]
class lvm_dimselect(vals, model, data_visualize, latent_axes=None, sense_axes=None, latent_index=[0, 1], labels=None)[source]

Bases: GPy.plotting.matplot_dep.visualize.lvm

A visualizer for latent variable models which allows selection of the latent dimensions to use by clicking on a bar chart of their length scales.

For an example of the visualizer’s use try:

GPy.examples.dimensionality_reduction.BGPVLM_oil()

on_click(event)[source]
on_leave(event)[source]
class lvm_subplots(vals, Model, data_visualize, latent_axes=None, sense_axes=None)[source]

Bases: GPy.plotting.matplot_dep.visualize.lvm

latent_axes is a np array of dimension np.ceil(input_dim/2), one for each pair of the latent dimensions.

class matplotlib_show(vals, axes=None)[source]

Bases: GPy.plotting.matplot_dep.visualize.data_show

the matplotlib_show class is a base class for all visualization methods that use matplotlib. It is initialized with an axis. If the axis is set to None it creates a figure window.

close()[source]
class mocap_data_show(vals, axes=None, connect=None, color='b')[source]

Bases: GPy.plotting.matplot_dep.visualize.matplotlib_show

Base class for visualizing motion capture data.

draw_edges()[source]
draw_vertices()[source]
finalize_axes()[source]
finalize_axes_modify()[source]
initialize_axes(boundary=0.05)[source]

Set up the axes with the right limits and scaling.

initialize_axes_modify()[source]
modify(vals)[source]
process_values()[source]
class mocap_data_show_vpython(vals, scene=None, connect=None, radius=0.1)[source]

Bases: GPy.plotting.matplot_dep.visualize.vpython_show

Base class for visualizing motion capture data using visual module.

draw_edges()[source]
draw_vertices()[source]
modify(vals)[source]
modify_edges()[source]
modify_vertices()[source]
pos_axis(i, j)[source]
process_values()[source]
class skeleton_show(vals, skel, axes=None, padding=0, color='b')[source]

Bases: GPy.plotting.matplot_dep.visualize.mocap_data_show

data_show class for visualizing motion capture data encoded as a skeleton with angles.

process_values()[source]

Takes a set of angles and converts them to the x,y,z coordinates in the internal prepresentation of the class, ready for plotting.

Parameters:vals – the values that are being modelled.
wrap_around(lim, connect)[source]
class stick_show(vals, connect=None, axes=None)[source]

Bases: GPy.plotting.matplot_dep.visualize.mocap_data_show

Show a three dimensional point cloud as a figure. Connect elements of the figure together using the matrix connect.

process_values()[source]
class vector_show(vals, axes=None)[source]

Bases: GPy.plotting.matplot_dep.visualize.matplotlib_show

A base visualization class that just shows a data vector as a plot of vector elements alongside their indices.

modify(vals)[source]
class vpython_show(vals, scene=None)[source]

Bases: GPy.plotting.matplot_dep.visualize.data_show

the vpython_show class is a base class for all visualization methods that use vpython to display. It is initialized with a scene. If the scene is set to None it creates a scene window.

close()[source]
data_play(Y, visualizer, frame_rate=30)[source]

Play a data set using the data_show object given.

Y:the data set to be visualized.
Parameters:visualizer (data_show) – the data show objectwhether to display during optimisation

Example usage:

This example loads in the CMU mocap database (http://mocap.cs.cmu.edu) subject number 35 motion number 01. It then plays it using the mocap_show visualize object.

data = GPy.util.datasets.cmu_mocap(subject='35', train_motions=['01'])
Y = data['Y']
Y[:, 0:3] = 0.   # Make figure walk in place
visualize = GPy.util.visualize.skeleton_show(Y[0, :], data['skel'])
GPy.util.visualize.data_play(Y, visualize)

Module contents