pyg.twod module

pyg.twod.commit_publications(message=’automated commit’)[source]
pyg.twod.context(ctx=’writeup’)[source]
pyg.twod.force(val=True)[source]
pyg.twod.load(fname, svg=False)[source]
pyg.twod.metal_dim(ratio=’golden’)[source]
class pyg.twod.pyg2d(env=’plot’, polar=False, colors=’purdue’)[source]

Bases: object

A pyg.pyg2d object plots many two-dimensional data types.

The pyg2d class provides an access to matplotlib charting functions and some hook ins to making these functions easier to use and more repeatable. The constructor itself takes only one optional argument, env.

Todo

Add more color schemes and the ability to define and hook in color schemes manually.

Parameters:
  • env (plot, gui, or None) – The environement option defines where you are going to use the generated plot, with the default option being plot (or printing). If you are using this to generate plots for a gui, define this option as gui and the class will choose a prettier parameter set for your chart. Default: plot.
  • colors (pu, purdue, salabs, or ah) – The colors option defines the color scheme which will be used in the plotting. The ability to hook in schemes will be added. Default: purdue.
Returns:

the pyg2d object.

Return type:

pyg2d

add_arrow(x1, x2, y1, y2, string=”, axes=None, fc=‘0.5’, alpha=1.0, ha=’center’, va=’center’, arrowprops=None)[source]
add_bar(x, y, hold=True, facecolor=’gray’, alpha=0.5, name=’plot’)[source]
add_circle(x, y, r, fc=’red’, ec=’None’, alpha=0.5, axes=None, name=’plot’)[source]
add_data_pointer(x, curve=None, point=None, string=None, place=’up-right’, ha=’left’, axes=None, latex=True, fc=‘0.3’)[source]
add_hist(y, bins, facecolor=’gray’, alpha=0.5, name=’plot’)[source]
add_hline(y, xmin=None, xmax=None, ls=’solid’, lw=1.5, color=’black’, axes=None)[source]

pyg2d.add_hline draws a horizontal line.

pyg2d.add_hline draws a horizontal line from either the left axis to the right axis if xmin and xmax are not provided, otherwise it is drawn from xmin to xmax at y. Be careful not to change from linear to log scale AFTER using this function, as

\[\log\left(0\right)=-\infty\]

and this means the line will extend past the extents of the latex page.

Parameters:
  • y (float) – The ordinate axis coordinate of the line.
  • xmin (float) – The left extent of the line.
  • xmax (float) – The right extent of the line.
  • ls (string) – The style of the line, i.e. ‘-‘, ‘–’, ‘:’, etc.
  • lw (float) – The width of the line in pt.
  • color (string) – The color of the line.
  • axes (axes) – The axes object the line should be added to, if not current.
Returns:

None

add_hmeasure(x1, x2, y1, string=None, place=None, offset=0.01, axes=None, units=”, log=False)[source]
add_label(x, y, string, color=’black’)[source]
add_legend(axes=None)[source]
add_line(x, y, name=’plot’, xerr=None, yerr=None, linewidth=0.5, linestyle=None, linecolor=’black’, legend=True, axes=None, error_fill=False)[source]
add_line_xx(x, y, name=’plot’, xerr=None, yerr=None, linecolor=’black’, linewidth=0.5, linestyle=None, legend=True)[source]
add_line_yy(x, y, name=’plot’, xerr=None, yerr=None, linecolor=’black’, linewidth=0.5, linestyle=None, legend=True, axes=None)[source]
add_math_jax(filename)[source]
add_metadata(filename)[source]
add_reg_line(x, y, regtype=’lin’, name=’reg’, xerr=None, yerr=None, axes=None)[source]
add_subplot(subp=121, polar=False)[source]

pyg2d.add_subplot adds a grid in which you can make subplots.

pyg2d.add_subplot follows Matlab’s lead and allows you to plot several axes on one plot. The newly created axes is saved as pyg2d.ax2 - this should be expanded for more axes later.

Todo

Expand subplotting to be able to use more than two axes total.

Parameters:subp (int) – If kwarg subp is not defined, the default is to add a second plot in a 1x2 array. When subp is defined, it will follow that system (i.e. subp=234 means you have two rows and three columns and you are plotting in the 4th postition (2,1)).
Returns:None
add_text(x1, y1, string=None, ha=’center’, va=’center’, color=’#746C66’, rotation=0, axes=None, fontsize=None)[source]
add_to_legend(name=None, line=True, color=None, linestyle=None, alpha=1.0, axes=None)[source]
add_vline(x, ymin=None, ymax=None, ls=’solid’, lw=1.5, color=’black’, name=None, axes=None)[source]

pyg2d.add_vline draws a vertical line.

pyg2d.add_vline draws a vertical line from either the bottom axis to the top axis if ymin and ymax are not provided, otherwise it is drawn from ymin to ymax at x. Be careful not to change from linear to log scale AFTER using this function, as

\[\log\left(0\right)=-\infty\]

and this means the line will extend past the extents of the latex page.

Todo

Fix the latex page extents problem with \(-\infty\)

Parameters:
  • x (float) – The abscissa coordinate of the line.
  • ymin (float) – The lower extent of the line.
  • ymax (float) – The upper extent of the line.
  • ls (string) – The style of the line, i.e. ‘-‘, ‘–’, ‘:’, etc.
  • lw (float) – The width of the line in pt.
  • color (string) – The color of the line.
  • axes (axes) – The axes object the line should be added to, if not current.
Returns:

None

add_vmeasure(x1, y1, y2, string=None, place=None, offset=0.01, axes=None, units=”, log=False)[source]
add_xx(calfunc)[source]
add_yy(calfunc)[source]
static change_context(context)[source]
change_style(rcparamsarray)[source]
close()[source]
det_height(ratio=’golden’)[source]
equal_aspect_ratio()[source]
export(filename, sizes=None, formats=None, customsize=None, legloc=None, tight=True, ratio=’golden’, width=None, caption=”, force_pdf=False, force=False)[source]
export_fmt(filename, size, sizeofsizes, format)[source]
fill_between(x, y1, y2=None, fc=’red’, name=’plot’, ec=’None’, leg=True, axes=None, alpha=0.5, xmin=None, xmax=None, log=False)[source]
fill_betweenx(x1, x2, y, fc=’red’, name=’plot’, ec=’None’, leg=True, axes=None, alpha=0.5)[source]
fill_under_curve(curve, scale=0.0, *args, **kwargs)[source]
fit_lines_on()[source]
pyg2d.fit_lines_on turns on the connector lines for any
regression fits that are plotted
Returns:None
fit_markers_off()[source]
pyg2d.fit_markers_off turns off the data markers for any
fit lines that are plotted
Returns:None
instances = [<weakproxy at 0x2acb1e311418 to NoneType at 0x8fd4d0>]
static latex_string(string)[source]
leg_col_full_page = 4
leg_col_one_col = 2
leg_col_two_col = 3
legend(loc=1, exclude=’saljfdaljdfaslkjfd’, axes=None)[source]

pyg2d.legend shows the legend on the plot.

pyg2d.legend toggles the legend showing on. This is done by getting the included objects and titles from the matplotlib axis item, and then checking to see if there is the word ‘connector’ in that title. If there is that word, then the entry is discarded.

Parameters:
  • loc (int) – The location of the legend in counter-clockwise notation.
  • exclude (str) – Partial key string of legend entries to exclude
Returns:

None

lines_off()[source]

pyg2d.lines_off turns off the connector lines for all data sets.

Returns:None
lines_on()[source]

pyg2d.lines_on turns on the connector lines for all data sets.

Returns:None
linestyle = {0: ‘-‘, 1: ‘–’, 2: ‘-.’, 3: ‘:’}
log_log()[source]
long_name()[source]
marker = {0: ‘+’, 1: ‘.’, 2: ‘1’, 3: ‘2’, 4: ‘3’, 5: ‘4’}
markers_off()[source]

pyg2d.markers_off turns off the data markers for all data sets.

Returns:None
markers_on()[source]

pyg2d.markers_on turns on the data markers for all data sets.

Returns:None
publish_to(directory)[source]
remove_font_sizes(filename)[source]
semi_log_x(axes=None)[source]
semi_log_y(axes=None)[source]
set_size(size, sizeofsizes, customsize=None, legloc=None, tight=True, ratio=’golden’, width=None)[source]
show(caption=”, label=None, scale=None, interactive=False, need_string=False)[source]
sizestring = {‘1’: ‘onecolumn’, ‘fp’: ‘fullpage’, ‘none’: ”, ‘2’: ‘twocolumn’, ‘cs’: ‘customsize’}
stackplot(x, y, baseline=’zero’, axes=None, name=’stackplot’, **kwargs)[source]
title(title, axes=None)[source]

pyg2d.title adds a title to the plot.

Parameters:title (str) – the title to be added to the plot. The title can take LaTeX arguments.
Returns:None
update_yy()[source]
xlabel(label, axes=None)[source]

pyg2d.xlabel adds a label to the x-axis.

pyg2d.xlabel adds a label to the x-axis of the current axes (or other axis given by kwarg axes).

Parameters:
  • label (str) – The label added to the x-axis of the defined axis. The label can take LaTeX arguments and the ah style guide asks for labels given as ‘Label ($variable$) [$unit$]’.
  • axes (axes, or None) – If not None, this argument will apply the x-label to the provided axis.
Returns:

None

xlim(minx, maxx, axes=None)[source]

pyg2d.xlim limits the view of the x-axis to limits.

Parameters:
  • minx (float) – The minimum value of x that will be shown.
  • maxx (float) – The maximum value of x that will be shown.
  • axes (axes, or None) – If not None, this argument will apply the x-limit to the provided axis.
Returns:

None

xticks(ticks, labels, axes=None)[source]

pyg2d.xticks changes the ticks and labels to provided values.

pyg2d.xticks will move the ticks on the abscissa to the locations given in ticks and place the labels in list labels at those locations, repsectively.

Parameters:
  • ticks (list) – The values where the new tick labels will be placed on the x-axis.
  • labels (list) – The string labels for each tick.
  • axes (axes) – An axes to append these ticks to, if not current.
Returns:

None

ylabel(label, axes=None)[source]

pyg2d.ylabel adds a label to the y-axis.

pyg2d.ylabel adds a label to the y-axis of the current axes (or other axis given by kwarg axes). The label can take LaTeX arguments and the ah style guide asks for labels given as ‘Label ($variable$) [$unit$]’.

Parameters:
  • label (str) – The label added to the y-axis of the defined axis. The label can take LaTeX arguments and the ah style guide asks for labels given as ‘Label ($variable$) [$unit$]’.
  • axes (axes, or None) – If not None, this argument will apply the x-label to the provided axis.
Returns:

None

ylim(miny, maxy, axes=None)[source]

pyg2d.ylim limits the view of the y-axis to limits.

Parameters:
  • miny (float) – The minimum value of y that will be shown.
  • maxy (float) – The maximum value of y that will be shown.
  • axes (axes, or None) – If not None, this argument will apply the y-limit to the provided axis.
Returns:

None

yticks(ticks, labels, axes=None)[source]

pyg2d.yticks changes the ticks and labels to provided values.

pyg2d.yticks will move the ticks on the ordinate axis to the locations given in ticks and place the labels in list labels at those locations, repsectively.

Parameters:
  • ticks (list) – The values where the new tick labels will be placed on the y-axis.
  • labels (list) – The string labels for each tick.
  • axes (axes) – An axes to append these ticks to, if not current.
Returns:

None

pyg.twod.res(w=1080.0, ratio=’golden’)[source]
class pyg.twod.svg(filename)[source]

Bases: object

static get_height(fname)[source]
static get_width(fname)[source]
show(caption=”, label=None, scale=None, width=None, convert=True, need_string=False, bbox=None)[source]
pyg.twod.svg_show(filename, caption=”, label=None, scale=None, width=None, convert=True, need_string=False)[source]