jahplotlib_ng – plotting library based on matplotlib

jahplotlib

Release:©2009, v 0.1 Oct 2009 byjah

A plotting library using matplotlib. Requires external libary mx.DateTime found in eGenix mx Base.

Usage is based on instantiating suitable class with figure size (in pixels) and dpi, and calling its plotting method(s) with a dictionary containing data and other required/optional information. See documentation of individual classes and methods.

Revision history:
  • Oct 2009 first (0.1) version partially based on jahplotlib.py
class jahplotlib_ng._cPlotBase(size='800, 600', dpi=100)

Common base class for plotting classes.

Fig(nPlots=1, useAxesGrid=True, axesPad=0.10000000000000001)

Create a figure with nplots subplots with ncols columns (number of rows automatically calculated). If figure allready exists, return next subfig.

nplots total number of plots
useAxesGrid use AxesGrid instead of “normal” figure, default: True
axesPad padding (used with useAxesGrid)

Return list of all subplot axes (self.axes) if useAxesGrid==False, otherwise return ???

GetListDim(lst)
Return 0 if not a list, 1 ([]) if one-dim, 2 if two ([[]]), and 3 if three ([[[]]])
close()
Close current figure
datetime_TYPE
alias of datetime
dict_TYPE
alias of dict
dtLocators(ddays)
Return majorLocator, minorLocator, dateFormatter based on number of days (ddays)
list_TYPE
alias of list
tuple_TYPE
alias of tuple
class jahplotlib_ng.cPlotXY(size='800, 600', dpi=100)

Bases: jahplotlib_ng._cPlotBase

Plot (x,y) plots, where x can also be mx.DateTime or python datetime.

size fig size in pixels, “width,height”
dpi dots-per-inch
Plot(dd={}, figfiles='test.png', x='x', y='y')

Do x,y plot based on data/metadata in dict dd (and/or x,y). Write out graphic file(s) named in figfiles list. All the texts (labels, legends, ...) are plotted as mathtext if $...$. Most of the options (dd keys) have relatively usable defaults. Currently only one x- and y-axis/subfigure. All the plots have common x-axis scale (i.e. min/max). Uses AxesGrid from matplotlib toolkits.

Can plot only ONE PLOT/subfigure, but with several subfigures stacked vertically. Can handle missing values (== None).

dd data dictionary
figfiles (list of) result file(s), default: test.png
x ‘x’: dd[‘x’], otherwise list (see dd[‘x’] below)
y ‘y’: dd[‘y’], otherwise list (see dd[‘y’] below)

Data dict (dd) keys:

‘x’
[] all the plots have common x-list [[]] several subplots with separate x-vals
‘y’
[] for one fig, or [[]] several subplots
‘xerr’
x error (symmetric) in x units, format: see ‘x’ above -> ErrorBar plotting
‘yerr’
y error (symmetric) in y units, format: see ‘y’ above -> ErrorBar plotting
‘kwargs’

[{}] passed to pylab plot command

‘linestyle’,’ls’
‘-‘ ‘–’ ‘-.’ ‘:’ ‘steps’ ‘None’
‘linewidth’,’lw’
points
‘marker’
‘+’ ‘,’ ‘.’ ‘1’ ‘2’ ‘3’ ‘4’ ‘<’ ‘>’ ‘D’ ‘H’ ‘^’ ‘_’ ‘d’ ‘h’ ‘o’ ‘p’ ‘s’ ‘v’ ‘x’ ‘|’
‘markeredgecolor’,’mec’
color
‘markeredgewidth’,’mew’
points
‘markerfacecolor’,’mfc’
color
‘markersize’,’ms’
points
‘color’,’c’
line color
‘text’
[(xpos,ypos,u’text’,kwargs)], one text/subplot, kwargs defaults: {‘ha’:’center’,’va’:’center’}
‘xlabel’
‘x-axis label’, or also (‘label’,’option string’)
‘ylabel’
[‘y axis label(s)’], also [(‘label’,’option string’)]
‘title’
‘title’, also (‘title’,’option string’)
‘xgrid’
True (for default), or type (e.g. “color=’r’,linestyle=’-‘,lw=2”)
‘ygrid’
[True] (for default), or type (see above). NOTE: one common grid style for both x,ygrid is used for one subfigure (ygrid has priority)
‘yticklabelsize’
[size in points]
‘xticklabelsize’
size in points
‘lineat’
[(yval,’linetype’)], horisontal line at y==yval, lineprop: color, linestyle (ls), linewidth (lw),...
‘xminmax’
[(xmin,xmax)]
‘yminmax’
[(ymin,ymax)]
‘yminminmaxmax’
[(yminmin,ymaxmax)]
‘yformatter’
[‘yformats’]
‘ymaxnbins’
[n], number of MaxNLocator’s, default=5
‘ylog’
[True/False]
‘frame’
{‘left’:,’bottom’:,’right’:,’wspace”:,’hspace’:} (0-1)
Revision history:
  • 2009-10 first version based on jahplotlib.py

Table Of Contents

Previous topic

Welcome to epylib’s documentation!

This Page