Data visualisation

Tab.plot(x, y=None, z=None, style='.', x_title=None, y_title=None, z_title=None, x_range=None, y_range=None, z_range=None, color=None, legend=None, num_z_levels=10, z_contour=True, z_interpol='nn', diag_line=False, labels=None, max_num_labels=None, title=None, clear=True, save=False, **kwargs)

Function to plot values from your table in 1, 2 or 3 dimensions using Matplotlib

Parameters:
  • x (str) – column name for first dimension
  • y (str) – column name for second dimension
  • z (str) – column name for third dimension
  • style (str) – symbol style (e.g. ., -, x, o, +, *). For a complete list check (matplotlib docu).
  • x_title (str) – title for first dimension, if not specified it is automatically derived from column name
  • y_title (str) – title for second dimension, if not specified it is automatically derived from column name
  • z_title (str) – title for third dimension, if not specified it is automatically derived from column name
  • x_range (list of length two) – start and end value for first dimension (e.g. [start_x, end_x])
  • y_range (list of length two) – start and end value for second dimension (e.g. [start_y, end_y])
  • z_range (list of length two) – start and end value for third dimension (e.g. [start_z, end_z])
  • color (str) – color for data (e.g. b, g, r). For a complete list check (matplotlib docu).
  • legend (str) – legend label for data series
  • num_z_levels (int) – number of levels for third dimension
  • diag_line (bool) – draw diagonal line
  • labels (str) – column name containing labels to put on x-axis for one dimensional plot
  • max_num_labels (int) – limit maximum number of labels
  • title (str) – plot title, if not specified it is automatically derived from plotted column names
  • clear (bool) – clear old data from plot
  • save (str) – filename for saving plot
  • z_contour (bool) – draw contour lines
  • z_interpol (str) – interpolation method for 3-dimensional plot (one of ‘nn’, ‘linear’)
  • **kwargs – additional arguments passed to matplotlib
Returns:

the matplotlib.pyplot module

Examples: simple plotting functions

tab=Table(['a','b','c','d'],'iffi', a=range(5,0,-1),
                                    b=[x/2.0 for x in range(1,6)],
                                    c=[math.cos(x) for x in range(0,5)],
                                    d=range(3,8))

# one dimensional plot of column 'd' vs. index
plt=tab.Plot('d')
plt.show()

# two dimensional plot of 'a' vs. 'c'
plt=tab.Plot('a', y='c', style='o-')
plt.show()

# three dimensional plot of 'a' vs. 'c' with values 'b'
plt=tab.Plot('a', y='c', z='b')
# manually save plot to file
plt.savefig("plot.png")
Tab.plot_histogram(col, x_range=None, num_bins=10, normed=False, histtype='stepfilled', align='mid', x_title=None, y_title=None, title=None, clear=True, save=False, color=None, y_range=None)

Create a histogram of the data in col for the range x_range, split into num_bins bins and plot it using Matplotlib.

Parameters:
  • col (str) – column name with data
  • x_range (list of length two) – start and end value for first dimension (e.g. [start_x, end_x])
  • y_range (list of length two) – start and end value for second dimension (e.g. [start_y, end_y])
  • num_bins (int) – number of bins in range
  • color (str) – Color to be used for the histogram. If not set, color will be determined by matplotlib
  • normed (bool) – normalize histogram
  • histtype (str) – type of histogram (i.e. bar, barstacked, step, stepfilled). See (matplotlib docu).
  • align (str) – style of histogram (left, mid, right). See (matplotlib docu).
  • x_title (str) – title for first dimension, if not specified it is automatically derived from column name
  • y_title (str) – title for second dimension, if not specified it is automatically derived from column name
  • title (str) – plot title, if not specified it is automatically derived from plotted column names
  • clear (bool) – clear old data from plot
  • save (str) – filename for saving plot

Examples: simple plotting functions

tab=Table(['a'],'f', a=[math.cos(x*0.01) for x in range(100)])

# one dimensional plot of column 'd' vs. index
plt=tab.plot_histogram('a')
plt.show()
Tab.plot_hexbin(x, y, title=None, x_title=None, y_title=None, x_range=None, y_range=None, binning='log', colormap='jet', show_scalebar=False, scalebar_label=None, clear=True, save=False, show=False)

Create a heatplot of the data in col x vs the data in col y using matplotlib

Parameters:
  • x (str) – column name with x data
  • y (str) – column name with y data
  • title (str) – title of the plot, will be generated automatically if set to None
  • x_title – label of x-axis, will be generated automatically if set to None
  • y_title – label of y-axis, will be generated automatically if set to None
  • x_range (list of length two) – start and end value for first dimension (e.g. [start_x, end_x])
  • y_range (list of length two) – start and end value for second dimension (e.g. [start_y, end_y])
  • binning – type of binning. If set to None, the value of a hexbin will correspond to the number of datapoints falling into it. If set to ‘log’, the value will be the log with base 10 of the above value (log(i+1)). If an integer is provided, the number of a hexbin is equal the number of datapoints falling into it divided by the integer. If a list of values is provided, these values will be the lower bounds of the bins.
  • colormap – colormap, that will be used. Value can be every colormap defined in matplotlib or an own defined colormap. You can either pass a string with the name of the matplotlib colormap or a colormap object.
  • show_scalebar (bool) – If set to True, a scalebar according to the chosen colormap is shown
  • scalebar_label (str) – Label of the scalebar
  • clear (bool) – clear old data from plot
  • save (str) – filename for saving plot
  • show (bool) – directly show plot
Tab.plot_bar(cols, x_labels=None, x_labels_rotation='horizontal', y_title=None, title=None, colors=None, yerr_cols=None, width=0.8, bottom=0, legend=True, save=False)

Create a barplot of the data in cols. Every element of a column will be represented as a single bar. If there are several columns, each row will be grouped together.

Parameters:
  • cols – Column names with data. If cols is a string, every element of that column will be represented as a single bar. If cols is a list, every row resulting of these columns will be grouped together. Every value of the table still is represented by a single bar.
  • x_labels (list) – Label for every row on x-axis.
  • x_labels_rotation – Can either be ‘horizontal’, ‘vertical’ or a number that describes the rotation in degrees.
  • y_title (str) – Y-axis description
  • colors (list) – Colors of the different bars in each group. Must be a list of valid colornames in matplotlib. Length of color and cols must be consistent.
  • yerr_cols – Columns containing the y-error information. Can either be a string if only one column is plotted or a list otherwise. Length of yerr_cols and cols must be consistent.
  • width (float) – The available space for the groups on the x-axis is divided by the exact number of groups. The parameters width is the fraction of what is actually used. If it would be 1.0 the bars of the different groups would touch each other.
  • bottom (float) – Bottom
  • legend (bool) – Legend for color explanation, the corresponding column respectively.
  • save (str) – If set, a png image with name $save in the current working directory will be saved.
Title :

Title

Tab.plot_enrichment(score_col, class_col, score_dir='-', class_dir='-', class_cutoff=2.0, style='-', title=None, x_title=None, y_title=None, clear=True, save=None)

Plot an enrichment curve using matplotlib of column score_col classified according to class_col.

For more information about parameters of the enrichment, see compute_enrichment(), and for plotting see Plot().

Warning :The function depends on matplotlib
Tab.plot_roc(score_col, class_col, score_dir='-', class_dir='-', class_cutoff=2.0, style='-', title=None, x_title=None, y_title=None, clear=True, save=None)

Plot an ROC curve using matplotlib.

For more information about parameters of the ROC, see compute_roc(), and for plotting see Plot().

Warning :The function depends on matplotlib

Project Versions

Previous topic

Statistics and Data Analysis

Next topic

tap - Importing and Exporting Tabular Data

This Page