GPy.plotting.matplot_dep package

Submodules

GPy.plotting.matplot_dep.Tango module

GPy.plotting.matplot_dep.Tango.currentDark()[source]
GPy.plotting.matplot_dep.Tango.currentLight()[source]
GPy.plotting.matplot_dep.Tango.currentMedium()[source]
GPy.plotting.matplot_dep.Tango.fewerXticks(ax=None, divideby=2)[source]
GPy.plotting.matplot_dep.Tango.hex2rgb(hexcolor)[source]
GPy.plotting.matplot_dep.Tango.nextDark()[source]
GPy.plotting.matplot_dep.Tango.nextLight()[source]
GPy.plotting.matplot_dep.Tango.nextMedium()[source]
GPy.plotting.matplot_dep.Tango.removeRightTicks(ax=None)[source]
GPy.plotting.matplot_dep.Tango.removeUpperTicks(ax=None)[source]
GPy.plotting.matplot_dep.Tango.reset()[source]
GPy.plotting.matplot_dep.Tango.setDarkFigures()[source]
GPy.plotting.matplot_dep.Tango.setLightFigures()[source]

GPy.plotting.matplot_dep.base_plots module

GPy.plotting.matplot_dep.base_plots.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 pb.subplots() to get an array of axes

GPy.plotting.matplot_dep.base_plots.align_subplots(N, M, xlim=None, ylim=None)[source]

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

GPy.plotting.matplot_dep.base_plots.ax_default(fignum, ax)[source]
GPy.plotting.matplot_dep.base_plots.fewerXticks(ax=None, divideby=2)[source]
GPy.plotting.matplot_dep.base_plots.gpplot(x, mu, lower, upper, edgecol='#204a87', fillcol='#729fcf', ax=None, fignum=None, **kwargs)[source]
GPy.plotting.matplot_dep.base_plots.meanplot(x, mu, color='#204a87', ax=None, fignum=None, linewidth=2, **kw)[source]
GPy.plotting.matplot_dep.base_plots.removeRightTicks(ax=None)[source]
GPy.plotting.matplot_dep.base_plots.removeUpperTicks(ax=None)[source]
GPy.plotting.matplot_dep.base_plots.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

GPy.plotting.matplot_dep.base_plots.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.dim_reduction_plots module

GPy.plotting.matplot_dep.dim_reduction_plots.most_significant_input_dimensions(model, which_indices)[source]

Determine which dimensions should be plotted

GPy.plotting.matplot_dep.dim_reduction_plots.plot_latent(model, labels=None, which_indices=None, resolution=50, ax=None, marker='o', s=40, fignum=None, plot_inducing=False, legend=True, plot_limits=None, aspect='auto', updates=False, predict_kwargs={}, imshow_kwargs={})[source]
Parameters:
  • labels – a np.array of size model.num_data containing labels for the points (can be number, strings, etc)
  • resolution – the resolution of the grid on which to evaluate the predictive variance
GPy.plotting.matplot_dep.dim_reduction_plots.plot_magnification(model, labels=None, which_indices=None, resolution=60, ax=None, marker='o', s=40, fignum=None, plot_inducing=False, legend=True, aspect='auto', updates=False)[source]
Parameters:
  • labels – a np.array of size model.num_data containing labels for the points (can be number, strings, etc)
  • resolution – the resolution of the grid on which to evaluate the predictive variance
GPy.plotting.matplot_dep.dim_reduction_plots.plot_steepest_gradient_map(model, fignum=None, ax=None, which_indices=None, labels=None, data_labels=None, data_marker='o', data_s=40, resolution=20, aspect='auto', updates=False, **kwargs)[source]

GPy.plotting.matplot_dep.img_plots module

The module contains the tools for ploting 2D image visualizations

GPy.plotting.matplot_dep.img_plots.plot_2D_images(figure, arr, symmetric=False, pad=None, zoom=None, mode=None, interpolation='nearest')[source]

GPy.plotting.matplot_dep.inference_plots module

GPy.plotting.matplot_dep.inference_plots.plot_optimizer(optimizer)[source]
GPy.plotting.matplot_dep.inference_plots.plot_sgd_traces(optimizer)[source]

GPy.plotting.matplot_dep.kernel_plots module

GPy.plotting.matplot_dep.kernel_plots.add_bar_labels(fig, ax, bars, bottom=0)[source]
GPy.plotting.matplot_dep.kernel_plots.plot(kernel, x=None, fignum=None, ax=None, title=None, plot_limits=None, resolution=None, **mpl_kwargs)[source]

plot a kernel. :param x: the value to use for the other kernel argument (kernels are a function of two variables!) :param fignum: figure number of the plot :param ax: matplotlib axis to plot on :param title: the matplotlib title :param plot_limits: the range over which to plot the kernel :resolution: the resolution of the lines used in plotting :mpl_kwargs avalid keyword arguments to pass through to matplotlib (e.g. lw=7)

GPy.plotting.matplot_dep.kernel_plots.plot_ARD(kernel, fignum=None, ax=None, title='', legend=False, filtering=None)[source]

If an ARD kernel is present, plot a bar representation using matplotlib

Parameters:
  • fignum – figure number of the plot
  • ax – matplotlib axis to plot on
  • title – title of the plot, pass ‘’ to not print a title pass None for a generic title
  • filtering (list of names to use for ARD plot) – list of names, which to use for plotting ARD parameters. Only kernels which match names in the list of names in filtering will be used for plotting.
GPy.plotting.matplot_dep.kernel_plots.plot_bars(fig, ax, x, ard_params, color, name, bottom=0)[source]

GPy.plotting.matplot_dep.mapping_plots module

GPy.plotting.matplot_dep.mapping_plots.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

GPy.plotting.matplot_dep.maps.apply_bbox(sf, ax)[source]

Use bbox as xlim and ylim in ax

GPy.plotting.matplot_dep.maps.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

GPy.plotting.matplot_dep.maps.new_shape_string(sf, name, regex, field=2, type=None)[source]
GPy.plotting.matplot_dep.maps.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.
GPy.plotting.matplot_dep.maps.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

GPy.plotting.matplot_dep.maps.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
GPy.plotting.matplot_dep.maps.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.models_plots module

GPy.plotting.matplot_dep.models_plots.plot_fit(model, plot_limits=None, which_data_rows='all', which_data_ycols='all', fixed_inputs=[], levels=20, samples=0, fignum=None, ax=None, resolution=None, plot_raw=False, linecol='#204a87', fillcol='#729fcf', Y_metadata=None, data_symbol='kx')[source]
Plot the posterior of the GP.
  • In one dimension, the function is plotted with a shaded region identifying two standard deviations.
  • In two dimsensions, a contour-plot shows the mean predicted function
  • In higher dimensions, use fixed_inputs to plot the GP with some of the inputs fixed.

Can plot only part of the data and part of the posterior functions using which_data_rowsm which_data_ycols.

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_rows (‘all’ or a list of integers) – which of the training data to plot (default all)
  • which_data_ycols – when the data has several columns (independant outputs), only plot these
  • 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.
  • 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.
  • linecol – color of line to plot.
  • fillcol – color of fill
  • levels – for 2D plotting, the number of contour levels to use is ax is None, create a new figure
GPy.plotting.matplot_dep.models_plots.plot_fit_f(model, *args, **kwargs)[source]

Plot the GP’s view of the world, where the data is normalized and before applying a likelihood.

All args and kwargs are passed on to models_plots.plot.

GPy.plotting.matplot_dep.netpbmfile module

Read and write image data from respectively to Netpbm files.

This implementation follows the Netpbm format specifications at http://netpbm.sourceforge.net/doc/. No gamma correction is performed.

The following image formats are supported: PBM (bi-level), PGM (grayscale), PPM (color), PAM (arbitrary), XV thumbnail (RGB332, read-only).

Author:Christoph Gohlke
Organization:Laboratory for Fluorescence Dynamics, University of California, Irvine
Version:2013.01.18

Requirements

Examples

>>> im1 = numpy.array([[0, 1],[65534, 65535]], dtype=numpy.uint16)
>>> imsave('_tmp.pgm', im1)
>>> im2 = imread('_tmp.pgm')
>>> assert numpy.all(im1 == im2)
GPy.plotting.matplot_dep.netpbmfile.imread(filename, *args, **kwargs)[source]

Return image data from Netpbm file as numpy array.

args and kwargs are arguments to NetpbmFile.asarray().

>>> image = imread('_tmp.pgm')
GPy.plotting.matplot_dep.netpbmfile.imsave(filename, data, maxval=None, pam=False)[source]

Write image data to Netpbm file.

>>> image = numpy.array([[0, 1],[65534, 65535]], dtype=numpy.uint16)
>>> imsave('_tmp.pgm', image)
class GPy.plotting.matplot_dep.netpbmfile.NetpbmFile(arg=None, **kwargs)[source]

Bases: object

Read and write Netpbm PAM, PBM, PGM, PPM, files.

asarray(copy=True, cache=False, **kwargs)[source]

Return image data from file as numpy array.

close()[source]

Close open file. Future asarray calls might fail.

write(arg, **kwargs)[source]

Write instance to file.

GPy.plotting.matplot_dep.priors_plots module

GPy.plotting.matplot_dep.priors_plots.plot(prior)[source]
GPy.plotting.matplot_dep.priors_plots.univariate_plot(prior)[source]

GPy.plotting.matplot_dep.ssgplvm module

The module plotting results for SSGPLVM

class GPy.plotting.matplot_dep.ssgplvm.SSGPLVM_plot(model, imgsize)[source]

Bases: object

plot_inducing()[source]

GPy.plotting.matplot_dep.svig_plots module

GPy.plotting.matplot_dep.svig_plots.plot(model, ax=None, fignum=None, Z_height=None, **kwargs)[source]
GPy.plotting.matplot_dep.svig_plots.plot_traces(model)[source]

GPy.plotting.matplot_dep.variational_plots module

GPy.plotting.matplot_dep.variational_plots.plot(parameterized, fignum=None, ax=None, colors=None)[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.variational_plots.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

GPy.plotting.matplot_dep.visualize.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)
class GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.mocap_data_show(vals, axes=None, connect=None)[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 GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.skeleton_show(vals, skel, axes=None, padding=0)[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 GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.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 GPy.plotting.matplot_dep.visualize.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]

Module contents