Table Of Contents

Previous topic

Plotting

This Page

Module Details

Classes to plot TimeSeries with matplotlib.

Classes

TimeSeriesPlot

class TimeSeriesPlot(fig=None, *args, **kwargs)

Based on : SubPlot

Defines a subclass of matplotlib.axes.Subplot to plot time series.

A TimeSeries is associated with the plot. This time series is usually specified at the creation of the plot, through the optional parameter series. If no series is given at the creation, the first time series being plotted will be used as associated series.

The associated series is stored in the series attribute. It gives its frequency to the plot. This frequency can be accessed through the attribute freq. All the other series that will be plotted will be first converted to the freq frequency, using their asfreq method.

The same parameters used for the instanciation of a standard matplotlib.axes.Subplot are recognized.

Parameters:

series : {None, TimeSeries}, optional

The time series allocated to the plot.

Warning

  • Because the series to plot are first converted to the plot frequency, it is recommended when plotting several series to associate the plot with the series with the highest frequency, in order to keep a good level of detail.

Attributes

freq
xdata DateArray The array of dates corresponding to the x axis.
legendsymbols list  
legendlabels list List of the labels associated with each plot. The first label corresponds to the first plot, the second label to the second plot, and so forth.

Methods

acorr
add_artist
add_callback
add_collection
add_line
add_patch
add_table
add_yaxis
annotate
apply_aspect
arrow
autoscale_view
axhline
axhspan
axis
axvline
axvspan
bar
barbs
barh
boxplot
broken_barh
can_zoom
change_geometry
cla
clabel
clear
cohere
connect
contains
contains_point
contour
contourf
convert_xunits
convert_yunits
csd
disconnect
drag_pan
draw
draw_artist
end_pan
errorbar
fill
fill_between
fill_betweenx
findobj
format_coord
format_dateaxis
format_xdata
format_ydata
get_adjustable
get_alpha
get_anchor
get_animated
get_aspect
get_autoscale_on
get_autoscalex_on
get_autoscaley_on
get_axes
get_axes_locator
get_axis_bgcolor
get_axisbelow
get_child_artists
get_children
get_clip_box
get_clip_on
get_clip_path
get_contains
get_cursor_props
get_data_ratio
get_data_ratio_log
get_datelimits
get_datelims
get_dlim
get_figure
get_frame
get_frame_on
get_freq
get_geometry
get_gid
get_images
get_label
get_legend
get_legend_handles_labels
get_lines
get_navigate
get_navigate_mode
get_picker
get_position
get_rasterization_zorder
get_rasterized
get_renderer_cache
get_series
get_shared_x_axes
get_shared_y_axes
get_snap
get_tightbbox
get_title
get_transform
get_transformed_clip_path_and_affine
get_url
get_visible
get_window_extent
get_xaxis
get_xaxis_text1_transform
get_xaxis_text2_transform
get_xaxis_transform
get_xbound
get_xgridlines
get_xlabel
get_xlim
get_xmajorticklabels
get_xminorticklabels
get_xscale
get_xticklabels
get_xticklines
get_xticks
get_yaxis
get_yaxis_text1_transform
get_yaxis_text2_transform
get_yaxis_transform
get_ybound
get_ydata
get_ygridlines
get_ylabel
get_ylim
get_ymajorticklabels
get_yminorticklabels
get_yscale
get_yticklabels
get_yticklines
get_yticks
get_zorder
grid
has_data
have_units
hexbin
hist
hitlist
hlines
hold
imshow
in_axes
invert_xaxis
invert_yaxis
is_figure_set
is_first_col
is_first_row
is_last_col
is_last_row
is_transform_set
ishold
label_outer
legend
loglog
matshow
minorticks_off
minorticks_on
pchanged
pcolor
pcolorfast
pcolormesh
pick
pickable
pie
plot
plot_date
properties
psd
quiver
quiverkey
redraw_in_frame
relim
remove
remove_callback
reset_datelimits
reset_position
scatter
semilogx
semilogy
set
set_adjustable
set_alpha
set_anchor
set_animated
set_aspect
set_autoscale_on
set_autoscalex_on
set_autoscaley_on
set_axes
set_axes_locator
set_axis_bgcolor
set_axis_off
set_axis_on
set_axisbelow
set_clip_box
set_clip_on
set_clip_path
set_color_cycle
set_contains
set_cursor_props
set_datelimits
set_datelims
set_dlim
set_figure
set_frame_on
set_gid
set_label
set_lod
set_navigate
set_navigate_mode
set_picker
set_position
set_rasterization_zorder
set_rasterized
set_series
set_snap
set_title
set_transform
set_url
set_visible
set_xbound
set_xlabel
set_xlim
set_xscale
set_xticklabels
set_xticks
set_ybound
set_ydata
set_ylabel
set_ylim
set_yscale
set_yticklabels
set_yticks
set_zorder
specgram
spy
start_pan
stem
step
table
text
ticklabel_format
tsplot
twinx
twiny
update
update_datalim
update_datalim_bounds
update_datalim_numerix
update_from
update_params
vlines
xaxis_date
xaxis_inverted
xcorr
yaxis_date
yaxis_inverted

TimeSeriesFigure

class TimeSeriesFigure(**kwargs)

Based on matplotlib.figure.Figure

Create a new Figure object. All the subplots share the same time series.

The same parameters used for the creation of a standard Figure are accepted.

Parameters:

series : {None, TimeSeries}, optional

Underlying time series. All the subplots of the figure will share the same series.

figsize : {None, tuple}

Size of the figure, as a tuple (width, height) in inches. If None, defaults to rc figure.figsize.

dpi : {None, int}, optional

Resolution in dots per inches. If None, defaults to rc figure.dpi

facecolor : {None, string}, optional

Background color. If None, defaults to rc figure.facecolor.

edgecolor : {None, string}, optional

Border color. If None, defaults to rc figure.edgecolor.

linewidth : {float, None}

Width of the patch edge line.

frameon : {True, False}

Whether to draw the frame around the figure.

Methods

add_axes
add_axobserver
add_callback
add_subplot
add_tsplot
autofmt_xdate
clear
clf
colorbar
contains
convert_xunits
convert_yunits
delaxes
draw
draw_artist
figimage
findobj
gca
get_alpha
get_animated
get_axes
get_children
get_clip_box
get_clip_on
get_clip_path
get_contains
get_dpi
get_edgecolor
get_facecolor
get_figheight
get_figure
get_figwidth
get_frameon
get_gid
get_label
get_picker
get_rasterized
get_size_inches
get_snap
get_tightbbox
get_transform
get_transformed_clip_path_and_affine
get_url
get_visible
get_window_extent
get_zorder
ginput
have_units
hitlist
hold
is_figure_set
is_transform_set
legend
pchanged
pick
pickable
properties
remove
remove_callback
savefig
sca
set
set_alpha
set_animated
set_axes
set_canvas
set_clip_box
set_clip_on
set_clip_path
set_contains
set_dpi
set_edgecolor
set_facecolor
set_figheight
set_figsize_inches
set_figure
set_figwidth
set_frameon
set_gid
set_label
set_lod
set_picker
set_rasterized
set_size_inches
set_snap
set_transform
set_url
set_visible
set_zorder
subplots_adjust
suptitle
text
update
update_from
waitforbuttonpress

Functions

add_yaxis(fsp=None, position='right', yscale=None, basey=10, subsy=None)

Adds a second y-axis to a TimeSeriesPlot. This function can also be used as a method.

Parameters:

fsp : {None, TimeSeriesPlot}

Subplot to which the secondary y-axis is added. If None, the current subplot is selected: in that case, it should be a valid TimeSeriesPlot. When used as a TimeSeriesPlot method, this parameter points automatically to the calling subplot.

position : {string}

Position of the new axis, as either 'left' or 'right'.

yscale : {string}

Scale of the new axis, as either 'log', 'linear' or None. If None, uses the same scale as the first y axis.

basey : {integer}

Base of the logarithm for the new axis (if needed).

subsy : {sequence}

Sequence of the location of the minor ticks; None defaults to autosubs, which depend on the number of decades in the plot. Eg for base 10, subsy=(1,2,5) will put minor ticks on 1, 2, 5, 11, 12,15, 21, .... To turn off minor ticking, set subsy=[].

Raises:

TypeError :

If the selected subplot is not a valid TimeSeriesPlot object.

add_tsplot(axes, *args, **kwargs)

Adds a TimeSeriesPlot to the current figure.

Parameters:

args : var

Mandatory arguments for the creation of the subplot. These arguments should be given as nb_of_rows, nb_of_columns, plot_number, or as a single 3-digit number if the 3 previous numbers are all lower than 10.

tsplot(series, *args, **kwargs)

Plots the series to the current TimeSeriesPlot. If the current plot is not a TimeSeriesPlot, a new TimeSeriesFigure is created.

Parameters:

series : TimeSeries

The time series to plot

args : var

Mandatory arguments for the creation of the subplot. These arguments should be given as nb_of_rows, nb_of_columns, plot_number, or as a single 3-digit number if the 3 previous numbers are all lower than 10.

kwargs : var

Optional arguments for the creation of the subplot.

tsfigure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True, subplotpars=None, series=None, FigureClass=<class 'scikits.timeseries.lib.plotlib.TimeSeriesFigure'>)

Creates a new TimeSeriesFigure object.

Parameters:

num : {None, int}, optional

Number of the figure. If None, a new figure is created and num is incremented.

figsize : {None, tuple}

Size of the figure, as a tuple (width, height) in inches. If None, defaults to rc figure.figsize.

dpi : {None, int}, optional

Resolution in dots per inches. If None, defaults to rc figure.dpi.

facecolor : {None, string}, optional

Background color. If None, defaults to rc figure.facecolor.

edgecolor : {None, string}, optional

Border color. If None, defaults to rc figure.edgecolor.

frameon : {True, False}

Whether to draw the frame around the figure.

subplotpars : {None, var}

A SubplotParams instance, defaults to rc

FigureClass : FigureClass

Class of the figure to create

Extensions to matplotlib

add_generic_subplot(figure_instance, *args, **kwargs)

Generalizes the matplotlib.Figure.add_subplot method of Figure to generic subplots. The specific Subplot object class to add is given through the keywords SubplotClass or class.

Parameters:

figure_instance : Figure object

Figure to which the generic subplot should be attached.

args : {var}

Miscellaneous arguments to the subplot.

kwargs : {Dictionary}

Optional keywords. The same keywords as Subplot are recognized, with the addition of:

  • SubplotClass : {string} Type of subplot.
  • subclass : {string} Shortcut to SubplotClass.
  • any keyword required by the SubplotClass subclass.

Ticks helpers

class TimeSeries_DateLocator(freq, minor_locator=False, dynamic_mode=True, base=1, quarter=1, month=1, day=1, plot_obj=None)

Locates the ticks along an axis controlled by a DateArray.

Parameters:

freq : {var}

Valid frequency specifier.

minor_locator : {False, True}, optional

Whether the locator is for minor ticks (True) or not.

dynamic_mode : {True, False}, optional

Whether the locator should work in dynamic mode.

base : {int}, optional

quarter : {int}, optional

month : {int}, optional

day : {int}, optional

Attributes

axis

Methods

DummyAxis
asmajor
asminor
autoscale
create_dummy_axis
pan
refresh
set_axis
set_bounds
set_data_interval
set_view_interval
view_limits
zoom
class TimeSeries_DateFormatter(freq, minor_locator=False, dynamic_mode=True, plot_obj=None)

Formats the ticks along an axis controlled by a DateArray.

Parameters:

freq : {int, string}

Valid frequency specifier.

minor_locator : {False, True}

Whether the current formatter should apply to minor ticks (True) or major ticks (False).

dynamic_mode : {True, False}

Whether the formatter works in dynamic mode or not.

Attributes

axis

Methods

DummyAxis
asmajor
asminor
create_dummy_axis
fix_minus
format_data
format_data_short
get_offset
set_axis
set_bounds
set_data_interval
set_locs
set_view_interval
author:Pierre GF Gerard-Marchant & Matt Knox
contact:pierregm_at_uga_dot_edu - mattknow_ca_at_hotmail_dot_com