Plots

ClusterPlot

class clusterking.plots.plot_clusters.ClusterPlot(data)[source]

Bases: object

Plot clusters in parameter space.

After initialization, use the ‘scatter’ or ‘fill’ method for plotting.

You can modify the attributes of this class to tweak some properties of the plots.

__init__(data)[source]
Parameters:dataData object
log = None

logging.Logger object

data = None

Instance of pandas.DataFrame

color_scheme = None

Color scheme

markers = None

List of markers of the get_clusters (scatter plot only).

max_subplots = None

Maximal number of subplots

max_cols = None

Maximal number of columns of the subplot grid

kv_formatter = None

Formatting of key-value pairs in title of plots

figsize = None

figure size of each subplot

cluster_column = None

The name of the column that holds the cluster index

bpoint_column = None

The name of the column that holds the benchmark yes/no information

default_marker_size = None

Default marker size

bpoint_marker_size = None

Marker size of benchmark points

draw_legend = None

If true, a legend is drawn

fig

The figure.

scatter(cols: List[str], clusters=None, **kwargs)[source]

Create scatter plot, specifying the columns to be on the axes of the plot. If 3 column are specified, 3D scatter plots are presented, else 2D plots. If the dataframe contains more columns, such that each row is not only specified by the columns on the axes, a selection of subplots is created, showing ‘cuts’. Benchmark points are marked by enlarged plot markers.

Parameters:
  • cols – The names of the columns to be shown on the x, y (and z) axis of the plots.
  • clusters – The get_clusters to be plotted (default: all)
  • **kwargs – Kwargs for ax.scatter
Returns:

The figure (unless the ‘inline’ setting of matplotllib is detected).

fill(cols: List[str], kwargs_imshow=None)[source]

Call this method with two column names, x and y. The results are similar to those of 2D scatter plots as created by the scatter method, except that the coloring is expanded to the whole xy plane. Note: This method only works with uniformly sampled NP!

Parameters:
  • cols – List of name of column to be plotted on x-axis and on y-axis
  • kwargs_imshow – Additional keyword arguments to be passed to imshow
Returns:

The figure (unless the ‘inline’ setting of matplotllib is detected).

savefig(*args, **kwargs)[source]

Equivalent to ClusterPlot.fig.savefig(*args, **kwargs): Saves figure to file, e.g. ClusterPlot.savefig("test.pdf").

BundlePlot

class clusterking.plots.plot_bundles.BundlePlot(data)[source]

Bases: object

Plotting class to plot distributions by cluster in order to analyse which distributions get assigned to which cluster.

__init__(data)[source]
Parameters:dataData object
log = None

logging.Logger object

data = None

pandas dataframe

cluster_column = None

Name of the column holding the cluster number

color_scheme = None

Color scheme

draw_legend = None

Draw legend?

title = None

Override default titles with this title. If None, the default title is used.

ax = None

Instance of matplotlib.axes.Axes

fig

Instance of matplotlib.pyplot.figure

plot_bundles(clusters: Union[int, Iterable[int]] = None, nlines=0, ax=None, bpoints=True) → None[source]

Plot several examples of distributions for each cluster specified

Parameters:
  • clusters – List of clusters to selected or single cluster. If None (default), all clusters are chosen.
  • nlines – Number of example distributions of each cluster to be plotted
  • ax – Instance of matplotlib.axes.Axes to be plotted on. If None (default), a new axes object and figure is initialized and saved as self.ax and self.fig.
  • bpoints – Draw benchmark curve
Returns:

None

animate_bundle(cluster, n, benchmark=True)[source]
plot_minmax(clusters: Union[int, Iterable[int]] = None, ax=None, bpoints=True) → None[source]

Plot the minimum and maximum of each bin for the specified clusters.

Parameters:
  • clusters – List of clusters to selected or single cluster. If None (default), all clusters are chosen.
  • ax – Instance of matplotlib.axes.Axes to plot on. If None, a new one is instantiated.
  • bpoints – Plot reference
Returns:

None

box_plot(clusters: Union[int, Iterable[int]] = None, ax=None, whiskers=2.5, bpoints=True) → None[source]

Box plot of the bin contents of the distributions corresponding to selected clusters.

Parameters:
  • clusters – List of clusters to selected or single cluster. If None (default), all clusters are chosen.
  • ax – Instance of matplotlib.axes.Axes to plot on. If None, a new one is instantiated.
  • whiskers – Length of the whiskers of the box plot in units of IQR (interquartile range, containing 50% of all values). Default 2.5.
  • bpoints – Draw benchmarks?