Axes#

class gwpy.plot.Axes(
fig: Figure,
*args: tuple[float, float, float, float] | Bbox | int,
**kwargs,
)[source]#

Bases: Axes

GWpy customised Axes.

Methods Summary

colorbar([mappable, fraction])

Add a Colorbar to these Axes.

draw(renderer)

Draw the Artist (and its children) using the given renderer.

get_epoch()

Return the epoch for the current GPS scale/.

hist(x[, bins])

Compute and plot a histogram.

imshow(X[, cmap, norm])

Display an image, i.e. data on a 2D regular raster.

legend(*args, **kwargs)

Place a legend on the Axes.

pcolormesh(*args, **kwargs)

Create a pseudocolor plot with a non-regular rectangular grid.

plot_mmm(data[, lower, upper])

Plot a Series as a line, with a shaded region around it.

scatter(x, y[, s, c])

A scatter plot of y vs. x with varying marker size and/or color.

set(*[, adjustable, agg_filter, alpha, ...])

Set multiple properties at once.

set_epoch(epoch)

Set the epoch for the current GPS scale.

set_xlim([left, right, emit, auto, xmin, xmax])

Set the x-axis view limits.

tile(x, y, w, h[, color, anchor, ...])

Plot rectanguler tiles based onto these Axes.

Methods Documentation

colorbar(
mappable: AxesImage | Collection | None = None,
fraction: float = 0.0,
**kwargs,
) Colorbar[source]#

Add a Colorbar to these Axes.

Parameters:
mappablematplotlib data collection, optional

Collection against which to map the colouring, default will be the last added mappable artist (collection or image).

fractionfloat, optional

Fraction of space to steal from these Axes to make space for the new axes, default is 0.. Use fraction=.15 to match the upstream matplotlib default.

**kwargs

other keyword arguments to be passed to the Plot.colorbar() generator

Returns:
cbarColorbar

the newly added Colorbar

See also

Plot.colorbar
draw(renderer)#

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (Artist.get_visible returns False).

Parameters:
rendererRendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

get_epoch() float | None[source]#

Return the epoch for the current GPS scale/.

This method will fail if the current X-axis scale isn’t one of the GPS scales. See Plotting GPS time scales for more details.

hist(
x: ArrayLike | Sequence[ArrayLike],
bins: int | Sequence[float] | str | None = None,
**kwargs,
) tuple[numpy.ndarray | list[numpy.ndarray], numpy.ndarray, BarContainer | Polygon | list[BarContainer | Polygon]][source]#

Compute and plot a histogram.

This method uses numpy.histogram to bin the data in x and count the number of values in each bin, then draws the distribution either as a BarContainer or Polygon. The bins, range, density, and weights parameters are forwarded to numpy.histogram.

If the data has already been binned and counted, use bar or stairs to plot the distribution:

counts, bins = np.histogram(x)
plt.stairs(counts, bins)

Alternatively, plot pre-computed bins and counts using hist() by treating each bin as a single point with a weight equal to its count:

plt.hist(bins[:-1], bins, weights=counts)

The data input x can be a singular array, a list of datasets of potentially different lengths ([x0, x1, …]), or a 2D ndarray in which each column is a dataset. Note that the ndarray form is transposed relative to the list form. If the input is an array, then the return value is a tuple (n, bins, patches); if the input is a sequence of arrays, then the return value is a tuple ([n0, n1, …], bins, [patches0, patches1, …]).

Masked arrays are not supported.

Parameters:
x(n,) array or sequence of (n,) arrays

Input values, this takes either a single array or a sequence of arrays which are not required to be of the same length.

binsint or sequence or str, default: rcParams[“hist.bins”] (default: 10)

If bins is an integer, it defines the number of equal-width bins in the range.

If bins is a sequence, it defines the bin edges, including the left edge of the first bin and the right edge of the last bin; in this case, bins may be unequally spaced. All but the last (righthand-most) bin is half-open. In other words, if bins is:

[1, 2, 3, 4]

then the first bin is [1, 2) (including 1, but excluding 2) and the second [2, 3). The last bin, however, is [3, 4], which includes 4.

If bins is a string, it is one of the binning strategies supported by numpy.histogram_bin_edges: ‘auto’, ‘fd’, ‘doane’, ‘scott’, ‘stone’, ‘rice’, ‘sturges’, or ‘sqrt’.

rangetuple or None, default: None

The lower and upper range of the bins. Lower and upper outliers are ignored. If not provided, range is (x.min(), x.max()). Range has no effect if bins is a sequence.

If bins is a sequence or range is specified, autoscaling is based on the specified bin range instead of the range of x.

densitybool, default: False

If True, draw and return a probability density: each bin will display the bin’s raw count divided by the total number of counts and the bin width (density = counts / (sum(counts) * np.diff(bins))), so that the area under the histogram integrates to 1 (np.sum(density * np.diff(bins)) == 1).

If stacked is also True, the sum of the histograms is normalized to 1.

weights(n,) array_like or None, default: None

An array of weights, of the same shape as x. Each value in x only contributes its associated weight towards the bin count (instead of 1). If density is True, the weights are normalized, so that the integral of the density over the range remains 1.

cumulativebool or -1, default: False

If True, then a histogram is computed where each bin gives the counts in that bin plus all bins for smaller values. The last bin gives the total number of datapoints.

If density is also True then the histogram is normalized such that the last bin equals 1.

If cumulative is a number less than 0 (e.g., -1), the direction of accumulation is reversed. In this case, if density is also True, then the histogram is normalized such that the first bin equals 1.

bottomarray_like or float, default: 0

Location of the bottom of each bin, i.e. bins are drawn from bottom to bottom + hist(x, bins) If a scalar, the bottom of each bin is shifted by the same amount. If an array, each bin is shifted independently and the length of bottom must match the number of bins. If None, defaults to 0.

histtype{‘bar’, ‘barstacked’, ‘step’, ‘stepfilled’}, default: ‘bar’

The type of histogram to draw.

  • ‘bar’ is a traditional bar-type histogram. If multiple data are given the bars are arranged side by side.

  • ‘barstacked’ is a bar-type histogram where multiple data are stacked on top of each other.

  • ‘step’ generates a lineplot that is by default unfilled.

  • ‘stepfilled’ generates a lineplot that is by default filled.

align{‘left’, ‘mid’, ‘right’}, default: ‘mid’

The horizontal alignment of the histogram bars.

  • ‘left’: bars are centered on the left bin edges.

  • ‘mid’: bars are centered between the bin edges.

  • ‘right’: bars are centered on the right bin edges.

orientation{‘vertical’, ‘horizontal’}, default: ‘vertical’

If ‘horizontal’, barh will be used for bar-type histograms and the bottom kwarg will be the left edges.

rwidthfloat or None, default: None

The relative width of the bars as a fraction of the bin width. If None, automatically compute the width.

Ignored if histtype is ‘step’ or ‘stepfilled’.

logbool, default: False

If True, the histogram axis will be set to a log scale.

logbinsbool, optional

If True, use logarithmically-spaced histogram bins.

Default is False

colorcolor or list of color or None, default: None

Color or sequence of colors, one per dataset. Default (None) uses the standard line color sequence.

labelstr or list of str, optional

String, or sequence of strings to match multiple datasets. Bar charts yield multiple patches per dataset, but only the first gets the label, so that legend will work as expected.

stackedbool, default: False

If True, multiple data are stacked on top of each other If False multiple data are arranged side by side if histtype is ‘bar’ or on top of each other if histtype is ‘step’

Returns:
narray or list of arrays

The values of the histogram bins. See density and weights for a description of the possible semantics. If input x is an array, then this is an array of length nbins. If input is a sequence of arrays [data1, data2, ...], then this is a list of arrays with the values of the histograms for each of the arrays in the same order. The dtype of the array n (or of its element arrays) will always be float even if no weighting or normalization is used.

binsarray

The edges of the bins. Length nbins + 1 (nbins left edges and right edge of last bin). Always a single array even when multiple data sets are passed in.

patchesBarContainer or list of a single Polygon or list of such objects

Container of individual artists used to create the histogram or list of such containers if there are multiple input datasets.

Other Parameters:
dataindexable object, optional

If given, the following parameters also accept a string s, which is interpreted as data[s] if s is a key in data:

x, weights

**kwargs

Patch properties. The following properties additionally accept a sequence of values corresponding to the datasets in x: edgecolor, facecolor, linewidth, linestyle, hatch.

Added in version 3.10: Allowing sequences of values in above listed Patch properties.

See also

hist2d

2D histogram with rectangular bins

hexbin

2D histogram with hexagonal bins

stairs

Plot a pre-computed histogram

bar

Plot a pre-computed histogram

Notes

For large numbers of bins (>1000), plotting can be significantly accelerated by using stairs to plot a pre-computed histogram (plt.stairs(*np.histogram(data))), or by setting histtype to ‘step’ or ‘stepfilled’ rather than ‘bar’ or ‘barstacked’.

imshow(
X: ArrayLike | PIL.Image.Image,
cmap: str | Colormap | None = None,
norm: str | Normalize | None = None,
**kwargs,
) AxesImage[source]#

Display an image, i.e. data on a 2D regular raster.

If array is a Array2D (e.g. a Spectrogram), then the defaults are _different_ to those in the upstream imshow() method. Namely, the defaults are

  • origin='lower' (coordinates start in lower-left corner)

  • aspect='auto' (pixels are not forced to be square)

  • interpolation='none' (no image interpolation is used)

In all other usage, the defaults from the upstream matplotlib method are unchanged.

Parameters:
Xarray_like or PIL image

The image data.

cmapstr or Colormap, default: rcParams[“image.cmap”] (default: 'viridis')

The Colormap instance or registered colormap name used to map scalar data to colors.

normstr or Normalize, optional

The normalization method used to scale scalar data to the [0, 1] range before mapping to colors using cmap. By default, a linear scaling is used, mapping the lowest value to 0 and the highest to 1.

If given, this can be one of the following:

  • An instance of Normalize or one of its subclasses (see Colormap normalization).

  • A scale name, i.e. one of “linear”, “log”, “symlog”, “logit”, etc. For a list of available scales, call matplotlib.scale.get_scale_names(). In that case, a suitable Normalize subclass is dynamically generated and instantiated.

*args, **kwargs

All arguments and keywords are passed to the inherited imshow() method.

See also

matplotlib.axes.Axes.imshow

for details of the image rendering

legend(*args, **kwargs) Legend[source]#

Place a legend on the Axes.

Note

This method uses a custom default legend handler for Line2D objects, with increased linewidth relative to the upstream legend() method. To disable this, pass handler_map=None, or create and pass your own handler class. See Custom legends in GWpy for more details.

Call signatures:

legend()
legend(handles, labels)
legend(handles=handles)
legend(labels)

The call signatures correspond to the following different ways to use this method:

1. Automatic detection of elements to be shown in the legend

The elements to be added to the legend are automatically determined, when you do not pass in any extra arguments.

In this case, the labels are taken from the artist. You can specify them either at artist creation or by calling the set_label() method on the artist:

ax.plot([1, 2, 3], label='Inline label')
ax.legend()

or:

line, = ax.plot([1, 2, 3])
line.set_label('Label via method')
ax.legend()

Note

Specific artists can be excluded from the automatic legend element selection by using a label starting with an underscore, “_”. A string starting with an underscore is the default label for all artists, so calling Axes.legend without any arguments and without setting the labels manually will result in a UserWarning and an empty legend being drawn.

2. Explicitly listing the artists and labels in the legend

For full control of which artists have a legend entry, it is possible to pass an iterable of legend artists followed by an iterable of legend labels respectively:

ax.legend([line1, line2, line3], ['label1', 'label2', 'label3'])

3. Explicitly listing the artists in the legend

This is similar to 2, but the labels are taken from the artists’ label properties. Example:

line1, = ax.plot([1, 2, 3], label='label1')
line2, = ax.plot([1, 2, 3], label='label2')
ax.legend(handles=[line1, line2])

4. Labeling existing plot elements

Discouraged

This call signature is discouraged, because the relation between plot elements and labels is only implicit by their order and can easily be mixed up.

To make a legend for all artists on an Axes, call this function with an iterable of strings, one for each legend item. For example:

ax.plot([1, 2, 3])
ax.plot([5, 6, 7])
ax.legend(['First line', 'Second line'])
Parameters:
handleslist of (Artist or tuple of Artist), optional

A list of Artists (lines, patches) to be added to the legend. Use this together with labels, if you need full control on what is shown in the legend and the automatic mechanism described above is not sufficient.

The length of handles and labels should be the same in this case. If they are not, they are truncated to the smaller length.

If an entry contains a tuple, then the legend handler for all Artists in the tuple will be placed alongside a single label.

labelslist of str, optional

A list of labels to show next to the artists. Use this together with handles, if you need full control on what is shown in the legend and the automatic mechanism described above is not sufficient.

Returns:
Legend
Other Parameters:
locstr or pair of floats, default: rcParams[“legend.loc”] (default: 'best')

The location of the legend.

The strings 'upper left', 'upper right', 'lower left', 'lower right' place the legend at the corresponding corner of the axes.

The strings 'upper center', 'lower center', 'center left', 'center right' place the legend at the center of the corresponding edge of the axes.

The string 'center' places the legend at the center of the axes.

The string 'best' places the legend at the location, among the nine locations defined so far, with the minimum overlap with other drawn artists. This option can be quite slow for plots with large amounts of data; your plotting speed may benefit from providing a specific location.

The location can also be a 2-tuple giving the coordinates of the lower-left corner of the legend in axes coordinates (in which case bbox_to_anchor will be ignored).

For back-compatibility, 'center right' (but no other location) can also be spelled 'right', and each “string” location can also be given as a numeric value:

Location String

Location Code

‘best’ (Axes only)

0

‘upper right’

1

‘upper left’

2

‘lower left’

3

‘lower right’

4

‘right’

5

‘center left’

6

‘center right’

7

‘lower center’

8

‘upper center’

9

‘center’

10

bbox_to_anchorBboxBase, 2-tuple, or 4-tuple of floats

Box that is used to position the legend in conjunction with loc. Defaults to axes.bbox (if called as a method to Axes.legend) or figure.bbox (if figure.legend). This argument allows arbitrary placement of the legend.

Bbox coordinates are interpreted in the coordinate system given by bbox_transform, with the default transform Axes or Figure coordinates, depending on which legend is called.

If a 4-tuple or BboxBase is given, then it specifies the bbox (x, y, width, height) that the legend is placed in. To put the legend in the best location in the bottom right quadrant of the Axes (or figure):

loc='best', bbox_to_anchor=(0.5, 0., 0.5, 0.5)

A 2-tuple (x, y) places the corner of the legend specified by loc at x, y. For example, to put the legend’s upper right-hand corner in the center of the Axes (or figure) the following keywords can be used:

loc='upper right', bbox_to_anchor=(0.5, 0.5)
ncolsint, default: 1

The number of columns that the legend has.

For backward compatibility, the spelling ncol is also supported but it is discouraged. If both are given, ncols takes precedence.

propNone or FontProperties or dict

The font properties of the legend. If None (default), the current matplotlib.rcParams will be used.

fontsizeint or {‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’}

The font size of the legend. If the value is numeric the size will be the absolute font size in points. String values are relative to the current default font size. This argument is only used if prop is not specified.

labelcolorstr or list, default: rcParams[“legend.labelcolor”] (default: 'None')

The color of the text in the legend. Either a valid color string (for example, ‘red’), or a list of color strings. The labelcolor can also be made to match the color of the line or marker using ‘linecolor’, ‘markerfacecolor’ (or ‘mfc’), or ‘markeredgecolor’ (or ‘mec’).

Labelcolor can be set globally using rcParams[“legend.labelcolor”] (default: 'None'). If None, use rcParams[“text.color”] (default: 'black').

numpointsint, default: rcParams[“legend.numpoints”] (default: 1)

The number of marker points in the legend when creating a legend entry for a Line2D (line).

scatterpointsint, default: rcParams[“legend.scatterpoints”] (default: 1)

The number of marker points in the legend when creating a legend entry for a PathCollection (scatter plot).

scatteryoffsetsiterable of floats, default: [0.375, 0.5, 0.3125]

The vertical offset (relative to the font size) for the markers created for a scatter plot legend entry. 0.0 is at the base the legend text, and 1.0 is at the top. To draw all markers at the same height, set to [0.5].

markerscalefloat, default: rcParams[“legend.markerscale”] (default: 1.0)

The relative size of legend markers compared to the originally drawn ones.

markerfirstbool, default: True

If True, legend marker is placed to the left of the legend label. If False, legend marker is placed to the right of the legend label.

reversebool, default: False

If True, the legend labels are displayed in reverse order from the input. If False, the legend labels are displayed in the same order as the input.

Added in version 3.7.

frameonbool, default: rcParams[“legend.frameon”] (default: True)

Whether the legend should be drawn on a patch (frame).

fancyboxbool, default: rcParams[“legend.fancybox”] (default: True)

Whether round edges should be enabled around the FancyBboxPatch which makes up the legend’s background.

shadowNone, bool or dict, default: rcParams[“legend.shadow”] (default: False)

Whether to draw a shadow behind the legend. The shadow can be configured using Patch keywords. Customization via rcParams[“legend.shadow”] (default: False) is currently not supported.

framealphafloat, default: rcParams[“legend.framealpha”] (default: 0.8)

The alpha transparency of the legend’s background. If shadow is activated and framealpha is None, the default value is ignored.

facecolor“inherit” or color, default: rcParams[“legend.facecolor”] (default: 'inherit')

The legend’s background color. If "inherit", use rcParams[“axes.facecolor”] (default: 'white').

edgecolor“inherit” or color, default: rcParams[“legend.edgecolor”] (default: '0.8')

The legend’s background patch edge color. If "inherit", use rcParams[“axes.edgecolor”] (default: 'black').

mode{“expand”, None}

If mode is set to "expand" the legend will be horizontally expanded to fill the Axes area (or bbox_to_anchor if defines the legend’s size).

bbox_transformNone or Transform

The transform for the bounding box (bbox_to_anchor). For a value of None (default) the Axes’ transAxes transform will be used.

titlestr or None

The legend’s title. Default is no title (None).

title_fontpropertiesNone or FontProperties or dict

The font properties of the legend’s title. If None (default), the title_fontsize argument will be used if present; if title_fontsize is also None, the current rcParams[“legend.title_fontsize”] (default: None) will be used.

title_fontsizeint or {‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’}, default: rcParams[“legend.title_fontsize”] (default: None)

The font size of the legend’s title. Note: This cannot be combined with title_fontproperties. If you want to set the fontsize alongside other font properties, use the size parameter in title_fontproperties.

alignment{‘center’, ‘left’, ‘right’}, default: ‘center’

The alignment of the legend title and the box of entries. The entries are aligned as a single block, so that markers always lined up.

borderpadfloat, default: rcParams[“legend.borderpad”] (default: 0.4)

The fractional whitespace inside the legend border, in font-size units.

labelspacingfloat, default: rcParams[“legend.labelspacing”] (default: 0.5)

The vertical space between the legend entries, in font-size units.

handlelengthfloat, default: rcParams[“legend.handlelength”] (default: 2.0)

The length of the legend handles, in font-size units.

handleheightfloat, default: rcParams[“legend.handleheight”] (default: 0.7)

The height of the legend handles, in font-size units.

handletextpadfloat, default: rcParams[“legend.handletextpad”] (default: 0.8)

The pad between the legend handle and text, in font-size units.

borderaxespadfloat, default: rcParams[“legend.borderaxespad”] (default: 0.5)

The pad between the Axes and legend border, in font-size units.

columnspacingfloat, default: rcParams[“legend.columnspacing”] (default: 2.0)

The spacing between columns, in font-size units.

handler_mapdict or None

The custom dictionary mapping instances or types to a legend handler. This handler_map updates the default handler map found at matplotlib.legend.Legend.get_legend_handler_map.

draggablebool, default: False

Whether the legend can be dragged with the mouse.

See also

Figure.legend

Notes

Some artists are not supported by this function. See Legend guide for details.

Examples

pcolormesh(*args: ArrayLike, **kwargs) QuadMesh[source]#

Create a pseudocolor plot with a non-regular rectangular grid.

When using GWpy, this method can be called with a single argument that is an Array2D, for which the X and Y coordinate arrays will be determined from the indexing.

In all other usage, all args and kwargs are passed directly to pcolormesh().

Notes

Unlike the upstream matplotlib.axes.Axes.pcolormesh(), this method respects the current grid settings.

plot_mmm(
data: Series,
lower: Series | None = None,
upper: Series | None = None,
**kwargs,
) list[Artist][source]#

Plot a Series as a line, with a shaded region around it.

The data Series is drawn, while the lower and upper Series are plotted lightly below and above, with a fill between them and the data.

All three Series should have the same index array.

Parameters:
dataSeries

Data to plot normally.

lowerSeries

Lower boundary (on Y-axis) for shade.

upperSeries

Upper boundary (on Y-axis) for shade.

**kwargs

Any other keyword arguments acceptable for plot().

Returns:
artiststuple

All of the drawn artists:

  • Line2d for data,

  • Line2D for lower, if given

  • Line2D for upper, if given

  • PolyCollection for shading

See also

matplotlib.axes.Axes.plot

for a full description of acceptable *args and **kwargs

scatter(
x: float | ArrayLike,
y: float | ArrayLike,
s: float | ArrayLike | None = None,
c: ArrayLike | Sequence[ColorType] | ColorType | None = None,
**kwargs,
) PathCollection[source]#

A scatter plot of y vs. x with varying marker size and/or color.

Parameters:
x, yfloat or array_like, shape (n, )

The data positions.

sfloat or array_like, shape (n, ), optional

The marker size in points**2 (typographic points are 1/72 in.). Default is rcParams['lines.markersize'] ** 2.

The linewidth and edgecolor can visually interact with the marker size, and can lead to artifacts if the marker size is smaller than the linewidth.

If the linewidth is greater than 0 and the edgecolor is anything but ‘none’, then the effective size of the marker will be increased by half the linewidth because the stroke will be centered on the edge of the shape.

To eliminate the marker edge either set linewidth=0 or edgecolor=’none’.

carray_like or list of color or color, optional

The marker colors. Possible values:

  • A scalar or sequence of n numbers to be mapped to colors using cmap and norm.

  • A 2D array in which the rows are RGB or RGBA.

  • A sequence of colors of length n.

  • A single color format string.

Note that c should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. If you want to specify the same RGB or RGBA value for all points, use a 2D array with a single row. Otherwise, value-matching will have precedence in case of a size matching with x and y.

If you wish to specify a single color for all points prefer the color keyword argument.

Defaults to None. In that case the marker color is determined by the value of color, facecolor or facecolors. In case those are not specified or None, the marker color is determined by the next color of the Axes’ current “shape and fill” color cycle. This cycle defaults to rcParams[“axes.prop_cycle”] (default: cycler('color', ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf'])).

sortbycolorbool, optional, default: False

Sort scatter points by c array value, if given.

markerMarkerStyle, default: rcParams[“scatter.marker”] (default: 'o')

The marker style. marker can be either an instance of the class or the text shorthand for a particular marker. See matplotlib.markers for more information about marker styles.

cmapstr or Colormap, default: rcParams[“image.cmap”] (default: 'viridis')

The Colormap instance or registered colormap name used to map scalar data to colors.

This parameter is ignored if c is RGB(A).

normstr or Normalize, optional

The normalization method used to scale scalar data to the [0, 1] range before mapping to colors using cmap. By default, a linear scaling is used, mapping the lowest value to 0 and the highest to 1.

If given, this can be one of the following:

  • An instance of Normalize or one of its subclasses (see Colormap normalization).

  • A scale name, i.e. one of “linear”, “log”, “symlog”, “logit”, etc. For a list of available scales, call matplotlib.scale.get_scale_names(). In that case, a suitable Normalize subclass is dynamically generated and instantiated.

This parameter is ignored if c is RGB(A).

vmin, vmaxfloat, optional

When using scalar data and no explicit norm, vmin and vmax define the data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data. It is an error to use vmin/vmax when a norm instance is given (but using a str norm name together with vmin/vmax is acceptable).

This parameter is ignored if c is RGB(A).

alphafloat, default: None

The alpha blending value, between 0 (transparent) and 1 (opaque).

linewidthsfloat or array_like, default: rcParams[“lines.linewidth”] (default: 1.5)

The linewidth of the marker edges. Note: The default edgecolors is ‘face’. You may want to change this as well.

edgecolors{‘face’, ‘none’, None} or color or list of color, default: rcParams[“scatter.edgecolors”] (default: 'face')

The edge color of the marker. Possible values:

  • ‘face’: The edge color will always be the same as the face color.

  • ‘none’: No patch boundary will be drawn.

  • A color or sequence of colors.

For non-filled markers, edgecolors is ignored. Instead, the color is determined like with ‘face’, i.e. from c, colors, or facecolors.

colorizerColorizer or None, default: None

The Colorizer object used to map color to data. If None, a Colorizer object is created from a norm and cmap.

This parameter is ignored if c is RGB(A).

plotnonfinitebool, default: False

Whether to plot points with nonfinite c (i.e. inf, -inf or nan). If True the points are drawn with the bad colormap color (see Colormap.set_bad).

Returns:
PathCollection
Other Parameters:
dataindexable object, optional

If given, the following parameters also accept a string s, which is interpreted as data[s] if s is a key in data:

x, y, s, linewidths, edgecolors, c, facecolor, facecolors, color

**kwargsPathCollection properties

Properties: agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: array-like or float or None animated: bool antialiased or aa or antialiaseds: bool or list of bools array: array-like or None capstyle: CapStyle or {‘butt’, ‘projecting’, ‘round’} clim: (vmin: float, vmax: float) clip_box: BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None cmap: Colormap or str or None color: color or list of RGBA tuples edgecolor or ec or edgecolors: color or list of color or ‘face’ facecolor or facecolors or fc: color or list of color figure: Figure or SubFigure gid: str hatch: {‘/’, ‘\’, ‘|’, ‘-’, ‘+’, ‘x’, ‘o’, ‘O’, ‘.’, ‘*’} hatch_linewidth: unknown in_layout: bool joinstyle: JoinStyle or {‘miter’, ‘round’, ‘bevel’} label: object linestyle or dashes or linestyles or ls: str or tuple or list thereof linewidth or linewidths or lw: float or list of floats mouseover: bool norm: Normalize or str or None offset_transform or transOffset: Transform offsets: (N, 2) or (2,) array-like path_effects: list of AbstractPathEffect paths: unknown picker: None or bool or float or callable pickradius: float rasterized: bool sizes: numpy.ndarray or None sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: Transform url: str urls: list of str or None visible: bool zorder: float

See also

plot

To plot scatter plots when markers are identical in size and color.

Notes

  • The plot function will be faster for scatterplots where markers don’t vary in size or color.

  • Any or all of x, y, s, and c may be masked arrays, in which case all masks will be combined and only unmasked points will be plotted.

  • Fundamentally, scatter works with 1D arrays; x, y, s, and c may be input as N-D arrays, but within scatter they will be flattened. The exception is c, which will be flattened only if its size matches the size of x and y.

set(
*,
adjustable=<UNSET>,
agg_filter=<UNSET>,
alpha=<UNSET>,
anchor=<UNSET>,
animated=<UNSET>,
aspect=<UNSET>,
autoscale_on=<UNSET>,
autoscalex_on=<UNSET>,
autoscaley_on=<UNSET>,
axes_locator=<UNSET>,
axisbelow=<UNSET>,
box_aspect=<UNSET>,
clip_box=<UNSET>,
clip_on=<UNSET>,
clip_path=<UNSET>,
epoch=<UNSET>,
facecolor=<UNSET>,
forward_navigation_events=<UNSET>,
frame_on=<UNSET>,
gid=<UNSET>,
in_layout=<UNSET>,
label=<UNSET>,
mouseover=<UNSET>,
navigate=<UNSET>,
path_effects=<UNSET>,
picker=<UNSET>,
position=<UNSET>,
prop_cycle=<UNSET>,
rasterization_zorder=<UNSET>,
rasterized=<UNSET>,
sketch_params=<UNSET>,
snap=<UNSET>,
subplotspec=<UNSET>,
title=<UNSET>,
transform=<UNSET>,
url=<UNSET>,
visible=<UNSET>,
xbound=<UNSET>,
xlabel=<UNSET>,
xlim=<UNSET>,
xmargin=<UNSET>,
xscale=<UNSET>,
xticklabels=<UNSET>,
xticks=<UNSET>,
ybound=<UNSET>,
ylabel=<UNSET>,
ylim=<UNSET>,
ymargin=<UNSET>,
yscale=<UNSET>,
yticklabels=<UNSET>,
yticks=<UNSET>,
zorder=<UNSET>,
)#

Set multiple properties at once.

Supported properties are

Properties:

adjustable: {‘box’, ‘datalim’} agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: float or None anchor: (float, float) or {‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, …} animated: bool aspect: {‘auto’, ‘equal’} or float autoscale_on: bool autoscalex_on: unknown autoscaley_on: unknown axes_locator: Callable[[Axes, Renderer], Bbox] axisbelow: bool or ‘line’ box_aspect: float or None clip_box: BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None epoch: float, str facecolor or fc: color figure: Figure or SubFigure forward_navigation_events: bool or “auto” frame_on: bool gid: str in_layout: bool label: object mouseover: bool navigate: bool navigate_mode: unknown path_effects: list of AbstractPathEffect picker: None or bool or float or callable position: [left, bottom, width, height] or Bbox prop_cycle: Cycler rasterization_zorder: float or None rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None subplotspec: unknown title: str transform: Transform url: str visible: bool xbound: (lower: float, upper: float) xlabel: str xlim: (left: float, right: float) xmargin: float greater than -0.5 xscale: unknown xticklabels: unknown xticks: unknown ybound: (lower: float, upper: float) ylabel: str ylim: (bottom: float, top: float) ymargin: float greater than -0.5 yscale: unknown yticklabels: unknown yticks: unknown zorder: float

set_epoch(epoch: SupportsToGps) None[source]#

Set the epoch for the current GPS scale.

This method will fail if the current X-axis scale isn’t one of the GPS scales. See Plotting GPS time scales for more details.

Parameters:
epochfloat, str

GPS-compatible time or date object, anything parseable by to_gps() is fine.

set_xlim(
left=None,
right=None,
*,
emit=True,
auto=False,
xmin=None,
xmax=None,
)#

Set the x-axis view limits.

Parameters:
leftfloat, optional

The left xlim in data coordinates. Passing None leaves the limit unchanged.

The left and right xlims may also be passed as the tuple (left, right) as the first positional argument (or as the left keyword argument).

rightfloat, optional

The right xlim in data coordinates. Passing None leaves the limit unchanged.

emitbool, default: True

Whether to notify observers of limit change.

autobool or None, default: False

Whether to turn on autoscaling of the x-axis. True turns on, False turns off, None leaves unchanged.

xmin, xmaxfloat, optional

They are equivalent to left and right respectively, and it is an error to pass both xmin and left or xmax and right.

Returns:
left, right(float, float)

The new x-axis limits in data coordinates.

See also

get_xlim
set_xbound, get_xbound
invert_xaxis, xaxis_inverted

Notes

The left value may be greater than the right value, in which case the x-axis values will decrease from left to right.

Examples

>>> set_xlim(left, right)
>>> set_xlim((left, right))
>>> left, right = set_xlim(left, right)

One limit may be left unchanged.

>>> set_xlim(right=right_lim)

Limits may be passed in reverse order to flip the direction of the x-axis. For example, suppose x represents the number of years before present. The x-axis limits might be set like the following so 5000 years ago is on the left of the plot and the present is on the right.

>>> set_xlim(5000, 0)
tile(
x: ArrayLike,
y: ArrayLike,
w: ArrayLike,
h: ArrayLike,
color: ArrayLike | None = None,
anchor: Literal['center', 'll', 'lr', 'ul', 'ur'] = 'center',
edgecolors: ColorType | Sequence[ColorType] | None = 'face',
linewidth: float | Sequence[float] | None = 0.8,
**kwargs,
) PolyCollection[source]#

Plot rectanguler tiles based onto these Axes.

x and y give the anchor point for each tile, with w and h giving the extent in the X and Y axis respectively.

Parameters:
x, y, w, harray_like, shape (n, )

Input data

colorarray_like, shape (n, )

Array of amplitudes for tile color

anchorstr, optional

Anchor point for tiles relative to (x, y) coordinates, one of

  • 'center' - center tile on (x, y)

  • 'll' - (x, y) defines lower-left corner of tile

  • 'lr' - (x, y) defines lower-right corner of tile

  • 'ul' - (x, y) defines upper-left corner of tile

  • 'ur' - (x, y) defines upper-right corner of tile

edgecolorscolour or list of colors, optional

Edge colour for each tile. Default is the special value "face" which matches the edgecolor to the facecolor.

linewidthfloat, array of float, optional

Line width for each tile.

**kwargs

Other keywords are passed to PolyCollection().

Returns:
collectionPolyCollection

The collection of tiles drawn.

Examples

>>> import numpy
>>> from matplotlib import pyplot
>>> import gwpy.plot  # to get gwpy's Axes
>>> x = numpy.arange(10)
>>> y = numpy.arange(x.size)
>>> w = numpy.ones_like(x) * .8
>>> h = numpy.ones_like(x) * .8
>>> fig = pyplot.figure()
>>> ax = fig.gca()
>>> ax.tile(x, y, w, h, anchor='ll')
>>> pyplot.show()

(png)

../../_images/gwpy-plot-Axes-1.png