plotters module of the psy-transect psyplot plugin
Formatoption classes:
|
Specify what to use for the x-axis |
|
Transect within a 2D plot |
|
Specify the method how to select the transect. |
|
Expand the transect to a minimum resolution. |
|
Specify the coordinate system of the data |
|
Plotter classes:
|
|
|
- class psy_transect.plotters.AlternativeTransectXCoord(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)
Bases:
Formatoption
Specify what to use for the x-axis
Possible types
'index'
Will use the index of the cell along the transect
'distance'
Will use the euclidean distance of the start of the transect
'haversine'
Will use the haversine distance in kilometers of the start of the transect. This can only be used if the x- and y-coordinates have units in
'degrees_east'
and'degrees_north'
, or'radian'
respectively.'x'
Will use the x-coordinate of the initial array
'y'
Will use the y-coordinate of the initial array
Attributes:
list of str.
str
.int
.transect Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- dependencies = ['transect']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Select the x-coordinate'
str
. A bit more verbose name than the formatoption key to be included in the gui. If None, the key is used in the gui
- priority = 30
int
. Priority value of the the formatoption determining when the formatoption is updated.10: at the end (for labels, etc.)
20: before the plotting (e.g. for colormaps, etc.)
30: before loading the data (e.g. for lonlatbox)
- property transect
transect Formatoption instance in the plotter
- update(value)
Method that is call to update the formatoption on the axes
- Parameters:
value – Value to update
- class psy_transect.plotters.Transect(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)
Bases:
Formatoption
Transect within a 2D plot
This formatoption takes a list of x-y tuples, the so-called transect, and extracts the raw data along this path.
Possible types
- list of x-y tuples
The point coordinates of the transect.
- None
Uses up to the first 100 cells
Attributes:
bool
or a callable.list of str.
str
.int
.transect_method Formatoption instance in the plotter
transect_resolution Formatoption instance in the plotter
Methods:
diff
(value)Checks whether the given value differs from what is currently set
update
(value)Method that is call to update the formatoption on the axes
- data_dependent = True
bool
or a callable. This attribute indicates whether thisFormatoption
depends on the data and should be updated if the data changes. If it is a callable, it must accept one argument: the new data. (Note: This is automatically set to True for plot formatoptions)
- dependencies = ['transect_method', 'transect_resolution']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- diff(value)
Checks whether the given value differs from what is currently set
- Parameters:
value – A possible value to set (make sure that it has been validate via the
validate
attribute before)- Returns:
True if the value differs from what is currently set
- Return type:
- name = 'Transect within the raw data'
str
. A bit more verbose name than the formatoption key to be included in the gui. If None, the key is used in the gui
- priority = 30
int
. Priority value of the the formatoption determining when the formatoption is updated.10: at the end (for labels, etc.)
20: before the plotting (e.g. for colormaps, etc.)
30: before loading the data (e.g. for lonlatbox)
- property transect_method
transect_method Formatoption instance in the plotter
- property transect_resolution
transect_resolution Formatoption instance in the plotter
- update(value)
Method that is call to update the formatoption on the axes
- Parameters:
value – Value to update
- class psy_transect.plotters.TransectMethod(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)
Bases:
Formatoption
Specify the method how to select the transect.
This formatoption specifies how the transect is selected.
Possible types
- ‘nearest’
Take the nearest grid point along the transect. This will not interpolate and return a unique list of grid points from the raw data.
- ‘nearest_exact’
Take the nearest grid point, one point from the raw data per point in the transect
- ‘inverse_distance_weighting’
Interpolation of the value at the requested position by inverse distance weighting method. See
pyinterp.RTree.inverse_distance_weighting()
- str
Any other method suitable for the rbf parameter of the
pyinterp.RTree.radial_basis_function()
method
Attributes:
str
.int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- name = 'Method for getting the data along the transect'
str
. A bit more verbose name than the formatoption key to be included in the gui. If None, the key is used in the gui
- priority = 30
int
. Priority value of the the formatoption determining when the formatoption is updated.10: at the end (for labels, etc.)
20: before the plotting (e.g. for colormaps, etc.)
30: before loading the data (e.g. for lonlatbox)
- update(value)
Method that is call to update the formatoption on the axes
- Parameters:
value – Value to update
- class psy_transect.plotters.TransectResolution(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)
Bases:
Formatoption
Expand the transect to a minimum resolution.
This formatoption expands the segments of the transect to fullfil a minimum resolution. Everything but
False
will expand the segments of the transect to fullfil the minimum resolution.This formatoption is of particular importance if you want to use the vertical transect plotter in combination with a map.
Possible types
False
Do not make any changes to the provided transect but take it as it is
True
or'auto'
The default value estimates the resolution of the underlying spatial data and estimates it’s minimum resolution. This won’t not work for unstructured data!
- float
Specify the spatial resolution directly
Attributes:
Estimate the resolution of the input data.
str
.Methods:
expand_path
(path)Expand the path segments to match the datas resolution.
expand_path_to_resolution
(path, resolution)Expand a given set of points to match the given resolution.
update
(value)Method that is call to update the formatoption on the axes
- expand_path(path: ndarray) ndarray
Expand the path segments to match the datas resolution.
- Parameters:
path (np.ndarray of shape (N, 2)) – The x-y-coordinates of the path segments
- Returns:
An array with
M>=N
where each segment in the path is smaller. than the minimum resolution.- Return type:
np.ndarray of shape (M, 2)
- static expand_path_to_resolution(path: ndarray, resolution: float) ndarray
Expand a given set of points to match the given resolution.
- Parameters:
path (np.ndarray of shape (N, 2)) – The x-y-coordinates of the path segments
resolution (float) – The minimum resolution that shall be used to expand the path
- Returns:
An array with
M>=N
where each segment in the path is smaller. than the minimum resolution.- Return type:
np.ndarray of shape (M, 2)
- name = 'Minimum resolution of the transect'
str
. A bit more verbose name than the formatoption key to be included in the gui. If None, the key is used in the gui
- update(value)
Method that is call to update the formatoption on the axes
- Parameters:
value – Value to update
- class psy_transect.plotters.VTransform(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)
Bases:
Transform
Specify the coordinate system of the data
This formatoption defines the coordinate system of the data (usually we expect a simple latitude longitude coordinate system)
Possible types
- cartopy.crs.CRS
A cartopy projection instance (e.g.
cartopy.crs.PlateCarree
)- str
A string specifies the projection instance to use. The centered longitude and latitude are determined by the
clon
andclat
formatoptions. Possible strings are (each standing for the specified projection)cf
try to decode the CF-conventions
cyl
cartopy.crs.PlateCarree
robin
cartopy.crs.Robinson
moll
cartopy.crs.Mollweide
geo
cartopy.crs.Geostationary
northpole
cartopy.crs.NorthPolarStereo
southpole
cartopy.crs.SouthPolarStereo
ortho
cartopy.crs.Orthographic
stereo
cartopy.crs.Stereographic
near
cartopy.crs.NearsidePerspective
rotated
cartopy.crs.RotatedPole
The special case
'cf'
tries to decode the CF-conventions in the data. If this is not possible, we assume a standard lat-lon projection ('cyl'
)
See also
Attributes:
list of str.
- class psy_transect.plotters.VerticalMapTransectPlotter(*args, **kwargs)
Bases:
VerticalTransectPlotter
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Set the x-axis limits
Set the y-axis limits
Color coding formatoptions:
Specify the boundaries of the colorbar
Specify the position of the colorbars
Specify the spacing of the bounds in the colorbar
Specify the color map
Specify the font properties of the colorbar ticklabels
Specify the font size of the colorbar ticklabels
Specify the fontweight of the colorbar ticklabels
Draw arrows at the side of the colorbar
The levels for the contour plot
Set the color for missing values
Label formatoptions:
Show the colorbar label
Properties of the Colorbar label
Set the size of the Colorbar label
Set the fontweight of the Colorbar label
Plot a figure title
Properties of the figure title
Set the size of the figure title
Set the fontweight of the figure title
Set the font properties of both, x- and y-label
Set the size of both, x- and y-label
Set the font size of both, x- and y-label
Add text anywhere on the plot
Show the title
Properties of the title
Set the size of the title
Set the fontweight of the title
Set the x-axis label
Set the y-axis label
Miscallaneous formatoptions:
Specify what to use for the x-axis
Show the grid of the data
Interpolate grid cell boundaries for 2D plots
Mask the datagrid where the array is NaN
Make x- and y-axis symmetric
Change the ticksize of the ticklabels
Change the fontweight of the ticks
Transect within a 2D plot
Specify the method how to select the transect.
Expand the transect to a minimum resolution.
Specify the coordinate system of the data
Axis tick formatoptions:
Specify the colorbar ticklabels
Specify the tick locations of the colorbar
Rotate the x-axis ticks
Modify the x-axis ticklabels
Specify the x-axis tick parameters
Modify the x-axis ticks
Rotate the y-axis ticks
Modify the y-axis ticklabels
Specify the y-axis tick parameters
Modify the y-axis ticks
Masking formatoptions:
Mask the data where a certain condition is True
Mask data points between two numbers
Mask data points greater than or equal to a number
Mask data points greater than a number
Mask data points smaller than or equal to a number
Mask data points smaller than a number
Plot formatoptions:
Specify the plotting method
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoptionAttributes:
- axiscolor
Color the x- and y-axes
This formatoption colors the left, right, bottom and top axis bar.
Possible types
- dict
Keys may be one of {‘right’, ‘left’, ‘bottom’, ‘top’}, the values can be any valid color or None.
Notes
The following color abbreviations are supported:
character
color
‘b’
blue
‘g’
green
‘r’
red
‘c’
cyan
‘m’
magenta
‘y’
yellow
‘k’
black
‘w’
white
In addition, you can specify colors in many weird and wonderful ways, including full names (
'green'
), hex strings ('#008000'
), RGB or RGBA tuples ((0,1,0,1)
) or grayscale intensities as a string ('0.8'
).
- background
The background color for the matplotlib axes.
Possible types
- ‘rc’
to use matplotlibs rc params
- None
to use a transparent color
- color
Any possible matplotlib color
- bounds
Specify the boundaries of the colorbar
Possible types
- None
make no normalization
- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten
- int
Specifies how many ticks to use with the
'rounded'
option. I.e. if integeri
, then this is the same as['rounded', i]
.- matplotlib.colors.Normalize
A matplotlib normalization instance
Examples
Plot 11 bounds over the whole data range:
>>> plotter.update(bounds='rounded')
which is equivalent to:
>>> plotter.update(bounds={'method': 'rounded'})
Plot 7 ticks over the whole data range where the maximal and minimal tick matches the data maximum and minimum:
>>> plotter.update(bounds=['minmax', 7])
which is equivaluent to:
>>> plotter.update(bounds={'method': 'minmax', 'N': 7})
chop the first and last five percentiles:
>>> plotter.update(bounds=['rounded', None, 5, 95])
which is equivalent to:
>>> plotter.update(bounds={'method': 'rounded', 'percmin': 5, ... 'percmax': 95})
Plot 3 bounds per power of ten:
>>> plotter.update(bounds=['log', 3])
Plot continuous logarithmic bounds:
>>> from matplotlib.colors import LogNorm >>> plotter.update(bounds=LogNorm())
See also
cmap
Specifies the colormap
- cbar
Specify the position of the colorbars
Possible types
- bool
True: defaults to ‘b’ False: Don’t draw any colorbar
- str
The string can be a combination of one of the following strings: {‘fr’, ‘fb’, ‘fl’, ‘ft’, ‘b’, ‘r’, ‘sv’, ‘sh’}
‘b’, ‘r’ stand for bottom and right of the axes
‘fr’, ‘fb’, ‘fl’, ‘ft’ stand for bottom, right, left and top of the figure
‘sv’ and ‘sh’ stand for a vertical or horizontal colorbar in a separate figure
- list
A containing one of the above positions
Examples
Draw a colorbar at the bottom and left of the axes:
>>> plotter.update(cbar='bl')
- cbarspacing
Specify the spacing of the bounds in the colorbar
Possible types
- str {‘uniform’, ‘proportional’}
if
'uniform'
, every color has exactly the same width in the colorbar, if'proportional'
, the size is chosen according to the data
- clabel
Show the colorbar label
Set the label of the colorbar. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The title for the
set_label()
method.
See also
- clabelprops
Properties of the Colorbar label
Specify the font properties of the figure title manually.
Possible types
- dict
Items may be any valid text property
See also
- clabelsize
Set the size of the Colorbar label
Possible types
- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- clabelweight
Set the fontweight of the Colorbar label
Possible types
- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- cmap
Specify the color map
This formatoption specifies the color coding of the data via a
matplotlib.colors.Colormap
Possible types
str
Strings may be any valid colormap name suitable for the
matplotlib.cm.get_cmap()
function or one of the color lists defined in the ‘colors.cmaps’ key of thepsyplot.rcParams
dictionary (including their reversed color maps given via the ‘_r’ extension).- matplotlib.colors.Colormap
The colormap instance to use
See also
bounds
specifies the boundaries of the colormap
- coord
Specify what to use for the x-axis
Possible types
'index'
Will use the index of the cell along the transect
'distance'
Will use the euclidean distance of the start of the transect
'haversine'
Will use the haversine distance in kilometers of the start of the transect. This can only be used if the x- and y-coordinates have units in
'degrees_east'
and'degrees_north'
, or'radian'
respectively.'x'
Will use the x-coordinate of the initial array
'y'
Will use the y-coordinate of the initial array
- cticklabels
Specify the colorbar ticklabels
Possible types
- str
A formatstring like
'%Y'
for plotting the year (in the case that time is shown on the axis) or ‘%i’ for integers- array
An array of strings to use for the ticklabels
See also
cticks
,cticksize
,ctickweight
,ctickprops
,vcticks
,vcticksize
,vctickweight
,vctickprops
- ctickprops
Specify the font properties of the colorbar ticklabels
Possible types
- dict
Items may be anything of the
matplotlib.pyplot.tick_params()
function
See also
cticksize
,ctickweight
,cticklabels
,cticks
,vcticksize
,vctickweight
,vcticklabels
,vcticks
- cticks
Specify the tick locations of the colorbar
Possible types
- None
use the default ticks
- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten- bounds
let the
bounds
keyword determine the ticks. An additional integer i may be specified to only use every i-th bound as a tick (see also int below)- midbounds
Same as bounds but in the middle between two bounds
- int
Specifies how many ticks to use with the
'bounds'
option. I.e. if integeri
, then this is the same as['bounds', i]
.
See also
- cticksize
Specify the font size of the colorbar ticklabels
Possible types
- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
ctickweight
,ctickprops
,cticklabels
,cticks
,vctickweight
,vctickprops
,vcticklabels
,vcticks
- ctickweight
Specify the fontweight of the colorbar ticklabels
Possible types
- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
cticksize
,ctickprops
,cticklabels
,cticks
,vcticksize
,vctickprops
,vcticklabels
,vcticks
- datagrid
Show the grid of the data
This formatoption shows the grid of the data (without labels)
Possible types
- None
Don’t show the data grid
- str
A linestyle in the form
'k-'
, where'k'
is the color and'-'
the linestyle.- dict
any keyword arguments that are passed to the plotting function (
matplotlib.pyplot.triplot()
for unstructured grids andmatplotlib.pyplot.hlines()
for rectilinear grids)
See also
mask_datagrid
To display cells with NaN
- extend
Draw arrows at the side of the colorbar
Possible types
- str {‘neither’, ‘both’, ‘min’ or ‘max’}
If not ‘neither’, make pointed end(s) for out-of-range values
- figtitle
Plot a figure title
Set the title of the figure. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The title for the
suptitle()
function
Notes
If the plotter is part of a
psyplot.project.Project
and multiple plotters of this project are on the same figure, the replacement attributes (see above) are joined by a delimiter. If thedelimiter
attribute of thisFigtitle
instance is not None, it will be used. Otherwise the rcParams[‘texts.delimiter’] item is used.This is the title of the whole figure! For the title of this specific subplot, see the
title
formatoption.
See also
- figtitleprops
Properties of the figure title
Specify the font properties of the figure title manually.
Possible types
- dict
Items may be any valid text property
See also
- figtitlesize
Set the size of the figure title
Possible types
- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- figtitleweight
Set the fontweight of the figure title
Possible types
- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- grid
Display the grid
Show the grid on the plot with the specified color.
Possible types
- None
If the grid is currently shown, it will not be displayed any longer. If the grid is not shown, it will be drawn
- bool
If True, the grid is displayed with the automatic settings (usually black)
- string, tuple.
Defines the color of the grid.
Notes
The following color abbreviations are supported:
character
color
‘b’
blue
‘g’
green
‘r’
red
‘c’
cyan
‘m’
magenta
‘y’
yellow
‘k’
black
‘w’
white
In addition, you can specify colors in many weird and wonderful ways, including full names (
'green'
), hex strings ('#008000'
), RGB or RGBA tuples ((0,1,0,1)
) or grayscale intensities as a string ('0.8'
).
- interp_bounds
Interpolate grid cell boundaries for 2D plots
This formatoption can be used to tell enable and disable the interpolation of grid cell boundaries. Usually, netCDF files only contain the centered coordinates. In this case, we interpolate the boundaries between the grid cell centers.
Possible types
- None
Interpolate the boundaries, except for circumpolar grids
- bool
If True (the default), the grid cell boundaries are inter- and extrapolated. Otherwise, if False, the coordinate centers are used and the default behaviour of matplotlib cuts of the most outer row and column of the 2D-data. Note that this results in a slight shift of the data
- labelprops
Set the font properties of both, x- and y-label
Possible types
- dict
A dictionary with the keys
'x'
and (or)'y'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is used for the x- and y-axis. The values in the dictionary can be one types below.- dict
Items may be any valid text property
See also
- labelsize
Set the size of both, x- and y-label
Possible types
- dict
A dictionary with the keys
'x'
and (or)'y'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is used for the x- and y-axis. The values in the dictionary can be one types below.- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- labelweight
Set the font size of both, x- and y-label
Possible types
- dict
A dictionary with the keys
'x'
and (or)'y'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is used for the x- and y-axis. The values in the dictionary can be one types below.- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- levels
The levels for the contour plot
This formatoption sets the levels for the filled contour plot and only has an effect if the
plot
Formatoption is set to'contourf'
Possible types
- None
Use the settings from the
bounds
formatoption and if this does not specify boundaries, use 11- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten
- int
Specifies how many ticks to use with the
'rounded'
option. I.e. if integeri
, then this is the same as['rounded', i]
.
- mask
Mask the data where a certain condition is True
This formatoption can be used to mask the plotting data based on another array. This array can be the name of a variable in the base dataset, or it can be a numeric array. Note that the data needs to be on exactly the same coordinates as the data shown here
Possible types
- None
Apply no mask
- str
The name of a variable in the base dataset to use.
dimensions that are in the given mask but not in the visualized base variable will be aggregated using
numpy.any()
if the given mask misses dimensions that are in the visualized data (i.e. the data of this plotter), we broadcast the mask to match the shape of the data
dimensions that are in mask and the base variable, but not in the visualized data will be matched against each other
- str
The path to a netCDF file that shall be loaded
- xr.DataArray or np.ndarray
An array that can be broadcasted to the shape of the data
- mask_datagrid
Mask the datagrid where the array is NaN
This boolean formatoption enables to mask the grid of the
datagrid
formatoption where the data is NaNPossible types
- bool
Either True, to not display the data grid for cells with NaN, or False
See also
- maskbetween
Mask data points between two numbers
Possible types
- float
The floating number to mask above
See also
- maskgeq
Mask data points greater than or equal to a number
Possible types
- float
The floating number to mask above
See also
- maskgreater
Mask data points greater than a number
Possible types
- float
The floating number to mask above
See also
- maskleq
Mask data points smaller than or equal to a number
Possible types
- float
The floating number to mask below
See also
- maskless
Mask data points smaller than a number
Possible types
- float
The floating number to mask below
See also
- miss_color
Set the color for missing values
Possible types
- None
Use the default from the colormap
- string, tuple.
Defines the color of the grid.
- plot
Specify the plotting method
Possible types
- None
Don’t make any plotting
- ‘mesh’
Use the
matplotlib.pyplot.pcolormesh()
function to make the plot
- post
Apply your own postprocessing script
This formatoption let’s you apply your own post processing script. Just enter the script as a string and it will be executed. The formatoption will be made available via the
self
variablePossible types
- None
Don’t do anything
- str
The post processing script as string
Note
This formatoption uses the built-in
exec()
function to compile the script. Since this poses a security risk when loading psyplot projects, it is by default disabled through thePlotter.enable_post
attribute. If you are sure that you can trust the script in this formatoption, set this attribute of the correspondingPlotter
toTrue
Examples
Assume, you want to manually add the mean of the data to the title of the matplotlib axes. You can simply do this via
from psyplot.plotter import Plotter from xarray import DataArray plotter = Plotter(DataArray([1, 2, 3])) # enable the post formatoption plotter.enable_post = True plotter.update(post="self.ax.set_title(str(self.data.mean()))") plotter.ax.get_title() "2.0"
By default, the
post
formatoption is only ran, when it is explicitly updated. However, you can use thepost_timing
formatoption, to run it automatically. E.g. for running it after every update of the plotter, you can setplotter.update(post_timing="always")
See also
post_timing
Determine the timing of this formatoption
- post_timing
Determine when to run the
post
formatoptionThis formatoption determines, whether the
post
formatoption should be run never, after replot or after every update.Possible types
- ‘never’
Never run post processing scripts
- ‘always’
Always run post processing scripts
- ‘replot’
Only run post processing scripts when the data changes or a replot is necessary
See also
post
The post processing formatoption
- selectors: Dict[Axes, widgets.LassoSelector]
- sym_lims
Make x- and y-axis symmetric
Possible types
- None
No symmetric type
- ‘min’
Use the minimum of x- and y-limits
- ‘max’
Use the maximum of x- and y-limits
- [str, str]
A combination,
None
,'min'
and'max'
specific for minimum and maximum limit
- text
Add text anywhere on the plot
This formatoption draws a text on the specified position on the figure. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
If string s: this will be used as (1., 1., s, {‘ha’: ‘right’}) (i.e. a string in the upper right corner of the axes).
- tuple or list of tuples (x,y,s[,coord.-system][,options]])
Each tuple defines a text instance on the plot. 0<=x, y<=1 are the coordinates. The coord.-system can be either the data coordinates (default,
'data'
) or the axes coordinates ('axes'
) or the figure coordinates (‘fig’). The string s finally is the text. options may be a dictionary to specify format the appearence (e.g.'color'
,'fontweight'
,'fontsize'
, etc., seematplotlib.text.Text
for possible keys). To remove one single text from the plot, set (x,y,’’[, coord.-system]) for the text at position (x,y)- empty list
remove all texts from the plot
- ticksize
Change the ticksize of the ticklabels
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- tickweight
Change the fontweight of the ticks
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- tight
Automatically adjust the plots.
If set to True, the plots are automatically adjusted to fit to the figure limitations via the
matplotlib.pyplot.tight_layout()
function.Possible types
- bool
True for automatic adjustment
Warning
There is no update method to undo what happend after this formatoption is set to True!
- title
Show the title
Set the title of the plot. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The title for the
title()
function.
Notes
This is the title of this specific subplot! For the title of the whole figure, see the
figtitle
formatoption.See also
- titleprops
Properties of the title
Specify the font properties of the figure title manually.
Possible types
- dict
Items may be any valid text property
See also
- titlesize
Set the size of the title
Possible types
- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- titleweight
Set the fontweight of the title
Possible types
- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- transect
Transect within a 2D plot
This formatoption takes a list of x-y tuples, the so-called transect, and extracts the raw data along this path.
Possible types
- list of x-y tuples
The point coordinates of the transect.
- None
Uses up to the first 100 cells
- transect_method
Specify the method how to select the transect.
This formatoption specifies how the transect is selected.
Possible types
- ‘nearest’
Take the nearest grid point along the transect. This will not interpolate and return a unique list of grid points from the raw data.
- ‘nearest_exact’
Take the nearest grid point, one point from the raw data per point in the transect
- ‘inverse_distance_weighting’
Interpolation of the value at the requested position by inverse distance weighting method. See
pyinterp.RTree.inverse_distance_weighting()
- str
Any other method suitable for the rbf parameter of the
pyinterp.RTree.radial_basis_function()
method
- transect_resolution
Expand the transect to a minimum resolution.
This formatoption expands the segments of the transect to fullfil a minimum resolution. Everything but
False
will expand the segments of the transect to fullfil the minimum resolution.This formatoption is of particular importance if you want to use the vertical transect plotter in combination with a map.
Possible types
False
Do not make any changes to the provided transect but take it as it is
True
or'auto'
The default value estimates the resolution of the underlying spatial data and estimates it’s minimum resolution. This won’t not work for unstructured data!
- float
Specify the spatial resolution directly
- transform
Specify the coordinate system of the data
This formatoption defines the coordinate system of the data (usually we expect a simple latitude longitude coordinate system)
Possible types
- cartopy.crs.CRS
A cartopy projection instance (e.g.
cartopy.crs.PlateCarree
)- str
A string specifies the projection instance to use. The centered longitude and latitude are determined by the
clon
andclat
formatoptions. Possible strings are (each standing for the specified projection)cf
try to decode the CF-conventions
cyl
cartopy.crs.PlateCarree
robin
cartopy.crs.Robinson
moll
cartopy.crs.Mollweide
geo
cartopy.crs.Geostationary
northpole
cartopy.crs.NorthPolarStereo
southpole
cartopy.crs.SouthPolarStereo
ortho
cartopy.crs.Orthographic
stereo
cartopy.crs.Stereographic
near
cartopy.crs.NearsidePerspective
rotated
cartopy.crs.RotatedPole
The special case
'cf'
tries to decode the CF-conventions in the data. If this is not possible, we assume a standard lat-lon projection ('cyl'
)
See also
- transpose
- xlabel
Set the x-axis label
Set the label for the x-axis. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The text for the
xlabel()
function.
See also
xlabelsize
,xlabelweight
,xlabelprops
- xlim
Set the x-axis limits
Possible types
- None
To not change the current limits
- str or list [str, str] or [[str, float], [str, float]]
Automatically determine the ticks corresponding to the data. The given string determines how the limits are calculated. The float determines the percentile to use A string can be one of the following:
- rounded
Sets the minimum and maximum of the limits to the rounded data minimum or maximum. Limits are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimum will always be lower or equal than the data minimum, the maximum will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the limits are chosen such that they are symmetric around zero
- minmax
Uses the minimum and maximum
- sym
Same as minmax but symmetric around zero
- tuple (xmin, xmax)
xmin is the smaller value, xmax the larger. Any of those values can be None or one of the strings (or lists) above to use the corresponding value here
See also
- xticklabels
Modify the x-axis ticklabels
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- str
A formatstring like
'%Y'
for plotting the year (in the case that time is shown on the axis) or ‘%i’ for integers- array
An array of strings to use for the ticklabels
See also
- xtickprops
Specify the x-axis tick parameters
This formatoption can be used to make a detailed change of the ticks parameters on the x-axis.
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- dict
Items may be anything of the
matplotlib.pyplot.tick_params()
function
See also
- xticks
Modify the x-axis ticks
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- None
use the default ticks
- int
for an integer i, only every i-th tick of the default ticks are used
- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten- hour
draw ticks every hour
- day
draw ticks every day
- week
draw ticks every week
- month, monthend, monthbegin
draw ticks in the middle, at the end or at the beginning of each month
- year, yearend, yearbegin
draw ticks in the middle, at the end or at the beginning of each year
For data, mid, hour, day, week, month, etc., the optional second value can be an integer i determining that every i-th data point shall be used (by default, it is set to 1). For rounded, roundedsym, minmax and sym, the second value determines the total number of ticks (defaults to 11).
Examples
Plot 11 ticks over the whole data range:
>>> plotter.update(xticks='rounded')
Plot 7 ticks over the whole data range where the maximal and minimal tick matches the data maximum and minimum:
>>> plotter.update(xticks=['minmax', 7])
Plot ticks every year and minor ticks every month:
>>> plotter.update(xticks={'major': 'year', 'minor': 'month'})
See also
- ylabel
Set the y-axis label
Set the label for the y-axis. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The text for the
ylabel()
function.
See also
ylabelsize
,ylabelweight
,ylabelprops
- ylim
Set the y-axis limits
Possible types
- None
To not change the current limits
- str or list [str, str] or [[str, float], [str, float]]
Automatically determine the ticks corresponding to the data. The given string determines how the limits are calculated. The float determines the percentile to use A string can be one of the following:
- rounded
Sets the minimum and maximum of the limits to the rounded data minimum or maximum. Limits are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimum will always be lower or equal than the data minimum, the maximum will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the limits are chosen such that they are symmetric around zero
- minmax
Uses the minimum and maximum
- sym
Same as minmax but symmetric around zero
- tuple (xmin, xmax)
xmin is the smaller value, xmax the larger. Any of those values can be None or one of the strings (or lists) above to use the corresponding value here
See also
- yticklabels
Modify the y-axis ticklabels
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- str
A formatstring like
'%Y'
for plotting the year (in the case that time is shown on the axis) or ‘%i’ for integers- array
An array of strings to use for the ticklabels
See also
- ytickprops
Specify the y-axis tick parameters
This formatoption can be used to make a detailed change of the ticks parameters of the y-axis.
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- dict
Items may be anything of the
matplotlib.pyplot.tick_params()
function
See also
- yticks
Modify the y-axis ticks
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- None
use the default ticks
- int
for an integer i, only every i-th tick of the default ticks are used
- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten- hour
draw ticks every hour
- day
draw ticks every day
- week
draw ticks every week
- month, monthend, monthbegin
draw ticks in the middle, at the end or at the beginning of each month
- year, yearend, yearbegin
draw ticks in the middle, at the end or at the beginning of each year
For data, mid, hour, day, week, month, etc., the optional second value can be an integer i determining that every i-th data point shall be used (by default, it is set to 1). For rounded, roundedsym, minmax and sym, the second value determines the total number of ticks (defaults to 11).
- class psy_transect.plotters.VerticalTransectPlotter(*args, **kwargs)
Bases:
Simple2DPlotter
Attributes:
The number of allowed dimensions in the for the visualization.
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Set the x-axis limits
Set the y-axis limits
Color coding formatoptions:
Specify the boundaries of the colorbar
Specify the position of the colorbars
Specify the spacing of the bounds in the colorbar
Specify the color map
Specify the font properties of the colorbar ticklabels
Specify the font size of the colorbar ticklabels
Specify the fontweight of the colorbar ticklabels
Draw arrows at the side of the colorbar
The levels for the contour plot
Set the color for missing values
Label formatoptions:
Show the colorbar label
Properties of the Colorbar label
Set the size of the Colorbar label
Set the fontweight of the Colorbar label
Plot a figure title
Properties of the figure title
Set the size of the figure title
Set the fontweight of the figure title
Set the font properties of both, x- and y-label
Set the size of both, x- and y-label
Set the font size of both, x- and y-label
Add text anywhere on the plot
Show the title
Properties of the title
Set the size of the title
Set the fontweight of the title
Set the x-axis label
Set the y-axis label
Methods:
connect_ax
(plotter_or_ax, **kwargs)Connect to a matplotlib axes via lasso.
disconnect_ax
(ax)Disconnect this plotter from an axes and remove the selector.
get_enhanced_attrs
(arr, *args, **kwargs)Miscallaneous formatoptions:
Specify what to use for the x-axis
Show the grid of the data
Interpolate grid cell boundaries for 2D plots
Mask the datagrid where the array is NaN
Make x- and y-axis symmetric
Change the ticksize of the ticklabels
Change the fontweight of the ticks
Transect within a 2D plot
Specify the method how to select the transect.
Expand the transect to a minimum resolution.
Axis tick formatoptions:
Specify the colorbar ticklabels
Specify the tick locations of the colorbar
Rotate the x-axis ticks
Modify the x-axis ticklabels
Specify the x-axis tick parameters
Modify the x-axis ticks
Rotate the y-axis ticks
Modify the y-axis ticklabels
Specify the y-axis tick parameters
Modify the y-axis ticks
Masking formatoptions:
Mask the data where a certain condition is True
Mask data points between two numbers
Mask data points greater than or equal to a number
Mask data points greater than a number
Mask data points smaller than or equal to a number
Mask data points smaller than a number
Plot formatoptions:
Specify the plotting method
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoption- allowed_dims = 3
The number of allowed dimensions in the for the visualization. If the array is unstructured, one dimension will be subtracted
- axiscolor
Color the x- and y-axes
This formatoption colors the left, right, bottom and top axis bar.
Possible types
- dict
Keys may be one of {‘right’, ‘left’, ‘bottom’, ‘top’}, the values can be any valid color or None.
Notes
The following color abbreviations are supported:
character
color
‘b’
blue
‘g’
green
‘r’
red
‘c’
cyan
‘m’
magenta
‘y’
yellow
‘k’
black
‘w’
white
In addition, you can specify colors in many weird and wonderful ways, including full names (
'green'
), hex strings ('#008000'
), RGB or RGBA tuples ((0,1,0,1)
) or grayscale intensities as a string ('0.8'
).
- background
The background color for the matplotlib axes.
Possible types
- ‘rc’
to use matplotlibs rc params
- None
to use a transparent color
- color
Any possible matplotlib color
- bounds
Specify the boundaries of the colorbar
Possible types
- None
make no normalization
- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten
- int
Specifies how many ticks to use with the
'rounded'
option. I.e. if integeri
, then this is the same as['rounded', i]
.- matplotlib.colors.Normalize
A matplotlib normalization instance
Examples
Plot 11 bounds over the whole data range:
>>> plotter.update(bounds='rounded')
which is equivalent to:
>>> plotter.update(bounds={'method': 'rounded'})
Plot 7 ticks over the whole data range where the maximal and minimal tick matches the data maximum and minimum:
>>> plotter.update(bounds=['minmax', 7])
which is equivaluent to:
>>> plotter.update(bounds={'method': 'minmax', 'N': 7})
chop the first and last five percentiles:
>>> plotter.update(bounds=['rounded', None, 5, 95])
which is equivalent to:
>>> plotter.update(bounds={'method': 'rounded', 'percmin': 5, ... 'percmax': 95})
Plot 3 bounds per power of ten:
>>> plotter.update(bounds=['log', 3])
Plot continuous logarithmic bounds:
>>> from matplotlib.colors import LogNorm >>> plotter.update(bounds=LogNorm())
See also
cmap
Specifies the colormap
- cbar
Specify the position of the colorbars
Possible types
- bool
True: defaults to ‘b’ False: Don’t draw any colorbar
- str
The string can be a combination of one of the following strings: {‘fr’, ‘fb’, ‘fl’, ‘ft’, ‘b’, ‘r’, ‘sv’, ‘sh’}
‘b’, ‘r’ stand for bottom and right of the axes
‘fr’, ‘fb’, ‘fl’, ‘ft’ stand for bottom, right, left and top of the figure
‘sv’ and ‘sh’ stand for a vertical or horizontal colorbar in a separate figure
- list
A containing one of the above positions
Examples
Draw a colorbar at the bottom and left of the axes:
>>> plotter.update(cbar='bl')
- cbarspacing
Specify the spacing of the bounds in the colorbar
Possible types
- str {‘uniform’, ‘proportional’}
if
'uniform'
, every color has exactly the same width in the colorbar, if'proportional'
, the size is chosen according to the data
- clabel
Show the colorbar label
Set the label of the colorbar. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The title for the
set_label()
method.
See also
- clabelprops
Properties of the Colorbar label
Specify the font properties of the figure title manually.
Possible types
- dict
Items may be any valid text property
See also
- clabelsize
Set the size of the Colorbar label
Possible types
- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- clabelweight
Set the fontweight of the Colorbar label
Possible types
- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- cmap
Specify the color map
This formatoption specifies the color coding of the data via a
matplotlib.colors.Colormap
Possible types
str
Strings may be any valid colormap name suitable for the
matplotlib.cm.get_cmap()
function or one of the color lists defined in the ‘colors.cmaps’ key of thepsyplot.rcParams
dictionary (including their reversed color maps given via the ‘_r’ extension).- matplotlib.colors.Colormap
The colormap instance to use
See also
bounds
specifies the boundaries of the colormap
- connect_ax(plotter_or_ax: HorizontalTransectPlotterMixin | Axes, **kwargs)
Connect to a matplotlib axes via lasso.
This creates a lasso to be used
- Parameters:
plotter_or_ax (VerticalTransectPlotter or matplotlib.axes.Axes) – The plotter whose axes to draw on, or an matplotlib axes. If you pass in the plotter, we make sure that lasso selectors of the plotter still work after an update.
- coord
Specify what to use for the x-axis
Possible types
'index'
Will use the index of the cell along the transect
'distance'
Will use the euclidean distance of the start of the transect
'haversine'
Will use the haversine distance in kilometers of the start of the transect. This can only be used if the x- and y-coordinates have units in
'degrees_east'
and'degrees_north'
, or'radian'
respectively.'x'
Will use the x-coordinate of the initial array
'y'
Will use the y-coordinate of the initial array
- cticklabels
Specify the colorbar ticklabels
Possible types
- str
A formatstring like
'%Y'
for plotting the year (in the case that time is shown on the axis) or ‘%i’ for integers- array
An array of strings to use for the ticklabels
See also
cticks
,cticksize
,ctickweight
,ctickprops
,vcticks
,vcticksize
,vctickweight
,vctickprops
- ctickprops
Specify the font properties of the colorbar ticklabels
Possible types
- dict
Items may be anything of the
matplotlib.pyplot.tick_params()
function
See also
cticksize
,ctickweight
,cticklabels
,cticks
,vcticksize
,vctickweight
,vcticklabels
,vcticks
- cticks
Specify the tick locations of the colorbar
Possible types
- None
use the default ticks
- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten- bounds
let the
bounds
keyword determine the ticks. An additional integer i may be specified to only use every i-th bound as a tick (see also int below)- midbounds
Same as bounds but in the middle between two bounds
- int
Specifies how many ticks to use with the
'bounds'
option. I.e. if integeri
, then this is the same as['bounds', i]
.
See also
- cticksize
Specify the font size of the colorbar ticklabels
Possible types
- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
ctickweight
,ctickprops
,cticklabels
,cticks
,vctickweight
,vctickprops
,vcticklabels
,vcticks
- ctickweight
Specify the fontweight of the colorbar ticklabels
Possible types
- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
cticksize
,ctickprops
,cticklabels
,cticks
,vcticksize
,vctickprops
,vcticklabels
,vcticks
- datagrid
Show the grid of the data
This formatoption shows the grid of the data (without labels)
Possible types
- None
Don’t show the data grid
- str
A linestyle in the form
'k-'
, where'k'
is the color and'-'
the linestyle.- dict
any keyword arguments that are passed to the plotting function (
matplotlib.pyplot.triplot()
for unstructured grids andmatplotlib.pyplot.hlines()
for rectilinear grids)
See also
mask_datagrid
To display cells with NaN
- disconnect_ax(ax: Axes)
Disconnect this plotter from an axes and remove the selector.
- extend
Draw arrows at the side of the colorbar
Possible types
- str {‘neither’, ‘both’, ‘min’ or ‘max’}
If not ‘neither’, make pointed end(s) for out-of-range values
- figtitle
Plot a figure title
Set the title of the figure. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The title for the
suptitle()
function
Notes
If the plotter is part of a
psyplot.project.Project
and multiple plotters of this project are on the same figure, the replacement attributes (see above) are joined by a delimiter. If thedelimiter
attribute of thisFigtitle
instance is not None, it will be used. Otherwise the rcParams[‘texts.delimiter’] item is used.This is the title of the whole figure! For the title of this specific subplot, see the
title
formatoption.
See also
- figtitleprops
Properties of the figure title
Specify the font properties of the figure title manually.
Possible types
- dict
Items may be any valid text property
See also
- figtitlesize
Set the size of the figure title
Possible types
- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- figtitleweight
Set the fontweight of the figure title
Possible types
- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- get_enhanced_attrs(arr, *args, **kwargs)
- grid
Display the grid
Show the grid on the plot with the specified color.
Possible types
- None
If the grid is currently shown, it will not be displayed any longer. If the grid is not shown, it will be drawn
- bool
If True, the grid is displayed with the automatic settings (usually black)
- string, tuple.
Defines the color of the grid.
Notes
The following color abbreviations are supported:
character
color
‘b’
blue
‘g’
green
‘r’
red
‘c’
cyan
‘m’
magenta
‘y’
yellow
‘k’
black
‘w’
white
In addition, you can specify colors in many weird and wonderful ways, including full names (
'green'
), hex strings ('#008000'
), RGB or RGBA tuples ((0,1,0,1)
) or grayscale intensities as a string ('0.8'
).
- interp_bounds
Interpolate grid cell boundaries for 2D plots
This formatoption can be used to tell enable and disable the interpolation of grid cell boundaries. Usually, netCDF files only contain the centered coordinates. In this case, we interpolate the boundaries between the grid cell centers.
Possible types
- None
Interpolate the boundaries, except for circumpolar grids
- bool
If True (the default), the grid cell boundaries are inter- and extrapolated. Otherwise, if False, the coordinate centers are used and the default behaviour of matplotlib cuts of the most outer row and column of the 2D-data. Note that this results in a slight shift of the data
- labelprops
Set the font properties of both, x- and y-label
Possible types
- dict
A dictionary with the keys
'x'
and (or)'y'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is used for the x- and y-axis. The values in the dictionary can be one types below.- dict
Items may be any valid text property
See also
- labelsize
Set the size of both, x- and y-label
Possible types
- dict
A dictionary with the keys
'x'
and (or)'y'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is used for the x- and y-axis. The values in the dictionary can be one types below.- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- labelweight
Set the font size of both, x- and y-label
Possible types
- dict
A dictionary with the keys
'x'
and (or)'y'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is used for the x- and y-axis. The values in the dictionary can be one types below.- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- levels
The levels for the contour plot
This formatoption sets the levels for the filled contour plot and only has an effect if the
plot
Formatoption is set to'contourf'
Possible types
- None
Use the settings from the
bounds
formatoption and if this does not specify boundaries, use 11- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten
- int
Specifies how many ticks to use with the
'rounded'
option. I.e. if integeri
, then this is the same as['rounded', i]
.
- mask
Mask the data where a certain condition is True
This formatoption can be used to mask the plotting data based on another array. This array can be the name of a variable in the base dataset, or it can be a numeric array. Note that the data needs to be on exactly the same coordinates as the data shown here
Possible types
- None
Apply no mask
- str
The name of a variable in the base dataset to use.
dimensions that are in the given mask but not in the visualized base variable will be aggregated using
numpy.any()
if the given mask misses dimensions that are in the visualized data (i.e. the data of this plotter), we broadcast the mask to match the shape of the data
dimensions that are in mask and the base variable, but not in the visualized data will be matched against each other
- str
The path to a netCDF file that shall be loaded
- xr.DataArray or np.ndarray
An array that can be broadcasted to the shape of the data
- mask_datagrid
Mask the datagrid where the array is NaN
This boolean formatoption enables to mask the grid of the
datagrid
formatoption where the data is NaNPossible types
- bool
Either True, to not display the data grid for cells with NaN, or False
See also
- maskbetween
Mask data points between two numbers
Possible types
- float
The floating number to mask above
See also
- maskgeq
Mask data points greater than or equal to a number
Possible types
- float
The floating number to mask above
See also
- maskgreater
Mask data points greater than a number
Possible types
- float
The floating number to mask above
See also
- maskleq
Mask data points smaller than or equal to a number
Possible types
- float
The floating number to mask below
See also
- maskless
Mask data points smaller than a number
Possible types
- float
The floating number to mask below
See also
- miss_color
Set the color for missing values
Possible types
- None
Use the default from the colormap
- string, tuple.
Defines the color of the grid.
- plot
Specify the plotting method
Possible types
- None
Don’t make any plotting
- ‘mesh’
Use the
matplotlib.pyplot.pcolormesh()
function to make the plot
- post
Apply your own postprocessing script
This formatoption let’s you apply your own post processing script. Just enter the script as a string and it will be executed. The formatoption will be made available via the
self
variablePossible types
- None
Don’t do anything
- str
The post processing script as string
Note
This formatoption uses the built-in
exec()
function to compile the script. Since this poses a security risk when loading psyplot projects, it is by default disabled through thePlotter.enable_post
attribute. If you are sure that you can trust the script in this formatoption, set this attribute of the correspondingPlotter
toTrue
Examples
Assume, you want to manually add the mean of the data to the title of the matplotlib axes. You can simply do this via
from psyplot.plotter import Plotter from xarray import DataArray plotter = Plotter(DataArray([1, 2, 3])) # enable the post formatoption plotter.enable_post = True plotter.update(post="self.ax.set_title(str(self.data.mean()))") plotter.ax.get_title() "2.0"
By default, the
post
formatoption is only ran, when it is explicitly updated. However, you can use thepost_timing
formatoption, to run it automatically. E.g. for running it after every update of the plotter, you can setplotter.update(post_timing="always")
See also
post_timing
Determine the timing of this formatoption
- post_timing
Determine when to run the
post
formatoptionThis formatoption determines, whether the
post
formatoption should be run never, after replot or after every update.Possible types
- ‘never’
Never run post processing scripts
- ‘always’
Always run post processing scripts
- ‘replot’
Only run post processing scripts when the data changes or a replot is necessary
See also
post
The post processing formatoption
- selectors: Dict[Axes, widgets.LassoSelector]
- sym_lims
Make x- and y-axis symmetric
Possible types
- None
No symmetric type
- ‘min’
Use the minimum of x- and y-limits
- ‘max’
Use the maximum of x- and y-limits
- [str, str]
A combination,
None
,'min'
and'max'
specific for minimum and maximum limit
- text
Add text anywhere on the plot
This formatoption draws a text on the specified position on the figure. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
If string s: this will be used as (1., 1., s, {‘ha’: ‘right’}) (i.e. a string in the upper right corner of the axes).
- tuple or list of tuples (x,y,s[,coord.-system][,options]])
Each tuple defines a text instance on the plot. 0<=x, y<=1 are the coordinates. The coord.-system can be either the data coordinates (default,
'data'
) or the axes coordinates ('axes'
) or the figure coordinates (‘fig’). The string s finally is the text. options may be a dictionary to specify format the appearence (e.g.'color'
,'fontweight'
,'fontsize'
, etc., seematplotlib.text.Text
for possible keys). To remove one single text from the plot, set (x,y,’’[, coord.-system]) for the text at position (x,y)- empty list
remove all texts from the plot
- ticksize
Change the ticksize of the ticklabels
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- tickweight
Change the fontweight of the ticks
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- tight
Automatically adjust the plots.
If set to True, the plots are automatically adjusted to fit to the figure limitations via the
matplotlib.pyplot.tight_layout()
function.Possible types
- bool
True for automatic adjustment
Warning
There is no update method to undo what happend after this formatoption is set to True!
- title
Show the title
Set the title of the plot. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The title for the
title()
function.
Notes
This is the title of this specific subplot! For the title of the whole figure, see the
figtitle
formatoption.See also
- titleprops
Properties of the title
Specify the font properties of the figure title manually.
Possible types
- dict
Items may be any valid text property
See also
- titlesize
Set the size of the title
Possible types
- float
The absolute font size in points (e.g., 12)
- string
Strings might be ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’.
See also
- titleweight
Set the fontweight of the title
Possible types
- float
a float between 0 and 1000
- string
Possible strings are one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
See also
- transect
Transect within a 2D plot
This formatoption takes a list of x-y tuples, the so-called transect, and extracts the raw data along this path.
Possible types
- list of x-y tuples
The point coordinates of the transect.
- None
Uses up to the first 100 cells
- transect_method
Specify the method how to select the transect.
This formatoption specifies how the transect is selected.
Possible types
- ‘nearest’
Take the nearest grid point along the transect. This will not interpolate and return a unique list of grid points from the raw data.
- ‘nearest_exact’
Take the nearest grid point, one point from the raw data per point in the transect
- ‘inverse_distance_weighting’
Interpolation of the value at the requested position by inverse distance weighting method. See
pyinterp.RTree.inverse_distance_weighting()
- str
Any other method suitable for the rbf parameter of the
pyinterp.RTree.radial_basis_function()
method
- transect_resolution
Expand the transect to a minimum resolution.
This formatoption expands the segments of the transect to fullfil a minimum resolution. Everything but
False
will expand the segments of the transect to fullfil the minimum resolution.This formatoption is of particular importance if you want to use the vertical transect plotter in combination with a map.
Possible types
False
Do not make any changes to the provided transect but take it as it is
True
or'auto'
The default value estimates the resolution of the underlying spatial data and estimates it’s minimum resolution. This won’t not work for unstructured data!
- float
Specify the spatial resolution directly
- transpose
- xlabel
Set the x-axis label
Set the label for the x-axis. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The text for the
xlabel()
function.
See also
xlabelsize
,xlabelweight
,xlabelprops
- xlim
Set the x-axis limits
Possible types
- None
To not change the current limits
- str or list [str, str] or [[str, float], [str, float]]
Automatically determine the ticks corresponding to the data. The given string determines how the limits are calculated. The float determines the percentile to use A string can be one of the following:
- rounded
Sets the minimum and maximum of the limits to the rounded data minimum or maximum. Limits are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimum will always be lower or equal than the data minimum, the maximum will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the limits are chosen such that they are symmetric around zero
- minmax
Uses the minimum and maximum
- sym
Same as minmax but symmetric around zero
- tuple (xmin, xmax)
xmin is the smaller value, xmax the larger. Any of those values can be None or one of the strings (or lists) above to use the corresponding value here
See also
- xticklabels
Modify the x-axis ticklabels
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- str
A formatstring like
'%Y'
for plotting the year (in the case that time is shown on the axis) or ‘%i’ for integers- array
An array of strings to use for the ticklabels
See also
- xtickprops
Specify the x-axis tick parameters
This formatoption can be used to make a detailed change of the ticks parameters on the x-axis.
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- dict
Items may be anything of the
matplotlib.pyplot.tick_params()
function
See also
- xticks
Modify the x-axis ticks
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- None
use the default ticks
- int
for an integer i, only every i-th tick of the default ticks are used
- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten- hour
draw ticks every hour
- day
draw ticks every day
- week
draw ticks every week
- month, monthend, monthbegin
draw ticks in the middle, at the end or at the beginning of each month
- year, yearend, yearbegin
draw ticks in the middle, at the end or at the beginning of each year
For data, mid, hour, day, week, month, etc., the optional second value can be an integer i determining that every i-th data point shall be used (by default, it is set to 1). For rounded, roundedsym, minmax and sym, the second value determines the total number of ticks (defaults to 11).
Examples
Plot 11 ticks over the whole data range:
>>> plotter.update(xticks='rounded')
Plot 7 ticks over the whole data range where the maximal and minimal tick matches the data maximum and minimum:
>>> plotter.update(xticks=['minmax', 7])
Plot ticks every year and minor ticks every month:
>>> plotter.update(xticks={'major': 'year', 'minor': 'month'})
See also
- ylabel
Set the y-axis label
Set the label for the y-axis. You can insert any meta key from the
xarray.DataArray.attrs
via a string like'%(key)s'
. Furthermore there are some special cases:Strings like
'%Y'
,'%b'
, etc. will be replaced using thedatetime.datetime.strftime()
method as long as the data has a time coordinate and this can be converted to adatetime
object.'%(x)s'
,'%(y)s'
,'%(z)s'
,'%(t)s'
will be replaced by the value of the x-, y-, z- or time coordinate (as long as this coordinate is one-dimensional in the data)any attribute of one of the above coordinates is inserted via
axis + key
(e.g. the name of the x-coordinate can be inserted via'%(xname)s'
).Labels defined in the
psyplot.rcParams
'texts.labels'
key are also replaced when enclosed by ‘{}’. The standard labels aretinfo:
%H:%M
dtinfo:
%B %d, %Y. %H:%M
dinfo:
%B %d, %Y
desc:
%(long_name)s [%(units)s]
sdesc:
%(name)s [%(units)s]
Possible types
- str
The text for the
ylabel()
function.
See also
ylabelsize
,ylabelweight
,ylabelprops
- ylim
Set the y-axis limits
Possible types
- None
To not change the current limits
- str or list [str, str] or [[str, float], [str, float]]
Automatically determine the ticks corresponding to the data. The given string determines how the limits are calculated. The float determines the percentile to use A string can be one of the following:
- rounded
Sets the minimum and maximum of the limits to the rounded data minimum or maximum. Limits are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimum will always be lower or equal than the data minimum, the maximum will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the limits are chosen such that they are symmetric around zero
- minmax
Uses the minimum and maximum
- sym
Same as minmax but symmetric around zero
- tuple (xmin, xmax)
xmin is the smaller value, xmax the larger. Any of those values can be None or one of the strings (or lists) above to use the corresponding value here
See also
- yticklabels
Modify the y-axis ticklabels
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- str
A formatstring like
'%Y'
for plotting the year (in the case that time is shown on the axis) or ‘%i’ for integers- array
An array of strings to use for the ticklabels
See also
- ytickprops
Specify the y-axis tick parameters
This formatoption can be used to make a detailed change of the ticks parameters of the y-axis.
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- dict
Items may be anything of the
matplotlib.pyplot.tick_params()
function
See also
- yticks
Modify the y-axis ticks
Possible types
- dict
A dictionary with the keys
'minor'
and (or)'major'
to specify which ticks are managed. If the given value is not a dictionary with those keys, it is put into a dictionary with the key determined by the rcParams'ticks.which'
key (usually'major'
). The values in the dictionary can be one types below.- None
use the default ticks
- int
for an integer i, only every i-th tick of the default ticks are used
- numeric array
specifies the ticks manually
- str or list [str, …]
A list of the below mentioned values of the mapping like
[method, N, percmin, percmax, vmin, vmax]
, where only the first one is absolutely necessary- dict
Automatically determine the ticks corresponding to the data. The mapping can have the following keys, but only method is not optional.
- N
An integer describing the number of boundaries (or ticks per power of ten, see log and symlog above)
- percmin
The percentile to use for the minimum (by default, 0, i.e. the minimum of the array)
- percmax
The percentile to use for the maximum (by default, 100, i.e. the maximum of the array)
- vmin
The minimum to use (in which case it is not calculated from the specified method)
- vmax
The maximum to use (in which case it is not calculated from the specified method)
- method
A string that defines how minimum and maximum shall be set. This argument is not optional and can be one of the following:
- data
plot the ticks exactly where the data is.
- mid
plot the ticks in the middle of the data.
- rounded
Sets the minimum and maximum of the ticks to the rounded data minimum or maximum. Ticks are rounded to the next 0.5 value with to the difference between data max- and minimum. The minimal tick will always be lower or equal than the data minimum, the maximal tick will always be higher or equal than the data maximum.
- roundedsym
Same as rounded above but the ticks are chose such that they are symmetric around zero
- minmax
Uses the minimum as minimal tick and maximum as maximal tick
- sym
Same as minmax but symmetric around zero
- log
Use logarithmic bounds. In this case, the given number N determines the number of bounds per power of tenth (i.e.
N == 2
results in something like1.0, 5.0, 10.0, 50.0
, etc., If this second number is None, then it will be chosen such that we have around 11 boundaries but at least one per power of ten.- symlog
The same as
log
but symmetric around 0. If the number N is None, then we have around 12 boundaries but at least one per power of ten- hour
draw ticks every hour
- day
draw ticks every day
- week
draw ticks every week
- month, monthend, monthbegin
draw ticks in the middle, at the end or at the beginning of each month
- year, yearend, yearbegin
draw ticks in the middle, at the end or at the beginning of each year
For data, mid, hour, day, week, month, etc., the optional second value can be an integer i determining that every i-th data point shall be used (by default, it is set to 1). For rounded, roundedsym, minmax and sym, the second value determines the total number of ticks (defaults to 11).