obspy.core.stream.Stream.plot

Stream.plot(*args, **kwargs)[source]

Creates a waveform plot of the current ObsPy Stream object.

param outfile:Output file string. Also used to automatically determine the output format. Supported file formats depend on your matplotlib backend. Most backends support png, pdf, ps, eps and svg. Defaults to None.
param format:Format of the graph picture. If no format is given the outfile parameter will be used to try to automatically determine the output format. If no format is found it defaults to png output. If no outfile is specified but a format is, than a binary imagestring will be returned. Defaults to None.
param starttime:
 Starttime of the graph as a UTCDateTime object. If not set the graph will be plotted from the beginning. Defaults to False.
param endtime:Endtime of the graph as a UTCDateTime object. If not set the graph will be plotted until the end. Defaults to False.
param fig:Use an existing matplotlib figure instance. Default to None.
param automerge:
 If automerge is True, Traces with the same id will be merged. Defaults to True.
param size:Size tuple in pixel for the output file. This corresponds to the resolution of the graph for vector formats. Defaults to (800, 250) pixel per channel.
param dpi:Dots per inch of the output file. This also affects the size of most elements in the graph (text, linewidth, ...). Defaults to 100.
param color:Color of the graph as a matplotlib color string as described below. If type='dayplot' a list/tuple of color strings is expected that will be periodically repeated for each line plotted. Defaults to 'black' or to ('#B2000F', '#004C12', '#847200', '#0E01FF') for type='dayplot'.
param bgcolor:Background color of the graph. Defaults to 'white'.
param face_color:
 Facecolor of the matplotlib canvas. Defaults to 'white'.
param transparent:
 Make all backgrounds transparent (True/False). This will overwrite the bgcolor and face_color arguments. Defaults to False.
param number_of_ticks:
 The number of ticks on the x-axis. Defaults to 4.
param tick_format:
 The way the time axis is formated. Defaults to '%H:%M:%S'.
param tick_rotation:
 Tick rotation in degrees. Default to 0.
param handle:Whether or not to return the matplotlib figure instance after the plot has been created. Defaults to False.
param method:By default, all traces with more than 400.000 samples will be plotted with a fast method that cannot be zoomed. Setting this argument to 'full' will straight up plot the data. This results in a potentially worse performance but the interactive matplotlib view can be used properly. Defaults to ‘fast’.
param type:Type may be set to either 'dayplot' in order to create a one-day plot for a single Trace or 'relative' to convert all date/time information to a relative scale, effectively starting the seismogram at 0 seconds. 'normal' will produce a standard plot. Defaults to 'normal'.
param equal_scale:
 Is enabled all plots are equally scaled. Defaults to True.

Dayplot parameters

The following parameters are only available if type='dayplot' is set.

param vertical_scaling_range:
 

Determines how each line is scaled in its given space. Every line will be centered around its mean value and then clamped to fit its given space. This argument is the range in data units that will be used to clamp the data. If the range is smaller than the actual range, the lines’ data may overshoot to other lines which is usually a desired effect. Larger ranges will result in a vertical padding. If 0, the actual range of the data will be used and no overshooting or additional padding will occur. If None the range will be chosen to be the 99.5-percentile of the actual range - so some values will overshoot. Defaults to None.

param interval:

This defines the interval length in minutes for one line.

param time_offset:
 

Only used if type='dayplot'. The difference between the timezone of the data (specified with the kwarg ‘timezone’) and UTC time in hours. Will be displayed in a string. Defaults to the current offset of the system time to UTC time.

param timezone:

Defines the name of the user defined time scale. Will be displayed in a string together with the actual offset defined in the kwarg ‘time_offset’. Defaults to 'local time'.

param localization_dict:
 

Enables limited localization of the dayplot through the usage of a dictionary. To change the labels to, e.g. german, use the following:

localization_dict={‘time in’: ‘Zeit in’, ‘seconds’: ‘Sekunden’,

‘minutes’: ‘Minuten’, ‘hours’: ‘Stunden’}

param data_unit:
 

If given, the scale of the data will be drawn on the right hand side in the form “%f {data_unit}”. The unit is supposed to be a string containing the actual unit of the data. Can be a LaTeX expression if matplotlib has been built with LaTeX support, e.g. “$frac{m}{s}$”. Be careful to escape the backslashes, or use r-prepended strings, e.g. r”$

rac{m}{s}$”.
param events:

An optional list of events can be drawn on the plot if given. They will be displayed as yellow stars with optional annotations. They are given as a list of dictionaries. Each dictionary at least needs to have a “time” key, containing a UTCDateTime object with the origin time of the event. Furthermore every event can have an optional “text” key which will then be displayed as an annotation. Example:

events=[{“time”: UTCDateTime(...), “text”: “Event A”}, {...}]

It can also be a Catalog object. In this case each event will be annotated with its corresponding Flinn-Engdahl region and the magnitude. Events can also be automatically downloaded with the help of obspy.neries. Just pass a dictionary with a “min_magnitude” key, e.g.

events={“min_magnitude”: 5.5}

Color Options

Colors can be specified as defined in the matplotlib.colors documentation.

Short Version: For all color values, you can either use:

  • legit HTML color names, e.g. 'blue',
  • HTML hex strings, e.g. '#EE00FF',
  • pass an string of a R, G, B tuple, where each of the component is a float value in the range of 0 to 1, e.g. '(1, 0.25, 0.5)', or
  • use a single letters for the basic built-in colors, such as 'b' (blue), 'g' (green), 'r' (red), 'c' (cyan), 'm' (magenta), 'y' (yellow), 'k' (black), 'w' (white).

Example

>>> from obspy import read
>>> st = read()
>>> st.plot() 

[hires.png, pdf]

../../_images/ecbd2f6c57.png

This Page