plotter

Utility functions facititating easy plotting with matplotlib.

Functions of note:

  • plot(): plot a regular plot, given input x,y-coordinates.
  • bar_graph(): plot a horizontal bar graph from x-coordinates and named groups of lists of y-corrdinates.
  • histogram(): plots a histogram from a set of samples and a given numbe of bins.
  • plot_degree_distribution(): plot the degree distribution provided a networkx graph.
Author:Kjetil Valle <kjetilva@stud.ntnu.no>
plotter.bar_graph(data, bar_names, x_label='', y_label='', title='', axis=None, colors=None, legend_place='lower right')

Create horzontal bar chart with lists of data values.

Plots a bar chart given a dictionary of data with a type as key, and a sequence of values corresponding to elements in bar_names as value.

Place legend with legend_place as string argument matching /(lower|middle|upper) (right|center|left)/.

plotter.histogram(samples, x_label='', y_label='', title='', axis=None, bins=10, range=None)

Create histogram from a set of samples.

Number of bins and range can be specified in the same manner as to numpy.histogram().

Crop/scale with axis as a 4-tuple of (x_min,x_max,y_min,y_max).

plotter.plot(x_vals, y_vals, x_label, y_label, title, axis=None, legend_place='lower right')

Plot a 2D plot from provided x- and y-values.

Given lists of x_vals and y_vals, a plot is drawn. Axes are labeled using x_label and y_label.

Plot can be cropped/scaled with axis as a 4-tuple of (x_min,x_max,y_min,y_max).

Place legend with legend_place as string argument matching /(lower|middle|upper) (right|center|left)/.

plotter.plot_degree_distribution(g)
Plot degree distribution for a graph g

Previous topic

evaluation

Next topic

util

This Page