psy_simple.plotters module
Plotters and formatoptions for the psy-simple plugin.
Formatoption classes:
|
Use an alternative variable as x-coordinate |
|
Use an alternative variable as x-coordinate |
|
Change the size of the arrows |
|
Change the style of the arrows |
|
Color the x- and y-axes |
|
Specify the transparency (alpha) |
|
Choose how to make the bar plot |
|
Specify the widths of the bars |
|
Modify the x-axis ticklabels |
|
Modify the x-axis ticks |
|
Set the x-axis label |
|
Set the x-axis limits |
|
Modify the y-axis ticklabels |
|
Modify the y-axis ticks |
|
Set the y-axis label |
|
Set the y-axis limits |
|
Specify the boundaries of the colorbar |
|
Show the colorbar label |
|
Specify the color map |
|
Specify the colorbar ticklabels |
|
Specify the font properties of the colorbar ticklabels |
|
Specify the font size of the colorbar ticklabels |
|
Specify the fontweight of the colorbar ticklabels |
|
Specify the tick locations of the colorbar |
|
The location of each bar |
|
Specify the position of the colorbars |
|
Base class for colorbar formatoptions |
|
Specify the spacing of the bounds in the colorbar |
|
Choose the vector plot type |
|
The levels for the contour plot |
|
Show the grid of the data |
|
Set the precision of the data |
|
Abstract base formatoption to calculate ticks and bounds from the data |
|
Change the density of the arrows |
|
Abstract base class for x- and y-tick formatoptions |
|
Set the alpha value for the error range |
|
Calculation of the error |
|
Visualize the error range |
|
Draw arrows at the side of the colorbar |
|
Display the grid |
|
Specify the range of the histogram for the x-dimension |
|
Specify the range of the histogram for the x-dimension |
|
Specify the bins of the 2D-Histogramm |
|
Interpolate grid cell boundaries for 2D plots |
|
Base formatoption class for label sizes |
|
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 |
|
Draw a legend |
|
Set the labels of the arrays in the legend |
|
Base class for x- and y-limits |
|
Set the color coding |
|
Choose the line style of the plot |
|
Choose the width of the lines |
|
Choose the marker for points |
|
Choose the size of the markers for points |
|
Mask the datagrid where the array is NaN |
|
Determine how the error is visualized |
|
Set the color for missing values |
|
Specify the normalization of the histogram |
|
Choose how to visualize a 2-dimensional scalar data field |
|
Specify the method to calculate the density |
|
Specify the plotting method |
|
Choose the vector plot type |
|
Make x- and y-axis symmetric |
|
|
|
Abstract base class for ticklabels |
|
Abstract base class for tick parameters |
|
Change the ticksize of the ticklabels |
|
Abstract base class for modifying tick sizes |
|
Change the fontweight of the ticks |
|
Abstract base class for modifying font weight of ticks |
|
Abstract base class for calculating ticks |
|
Abstract base class for ticks formatoptions controlling major and minor ticks |
|
Abstract base class for formatoptions handling ticks |
|
Base class for ticklabels options that apply for x- and y-axis |
|
Switch x- and y-axes |
|
Show the colorbar label of the vector plot |
|
Specify the boundaries of the vector colorbar |
|
Specify the tick locations of the vector colorbar |
|
Abstract formatoption that provides calculation functions for speed, etc. |
|
Specify the position of the vector plot colorbars |
|
Set the color for the arrows |
|
|
|
Change the linewidth of the arrows |
|
Choose the vector plot type |
|
Choose how to make the violin plot |
|
Modify the x-axis ticklabels |
|
Modify the x-axis ticks |
|
Set the x-axis limits |
|
Modify the x-axis ticklabels |
|
Modify the y-axis ticks |
|
Set the y-axis limits |
|
Rotate the x-axis ticks |
|
Modify the x-axis ticklabels |
|
Specify the x-axis tick parameters |
|
Modify the x-axis ticks |
|
Modify the x-axis ticks |
|
Set the x-axis label |
|
Set the x-axis limits |
|
Set the x-axis limits |
|
Rotate the y-axis ticks |
|
Modify the y-axis ticklabels |
|
Specify the y-axis tick parameters |
|
Modify the y-axis ticks |
|
Modify the y-axis ticks |
|
Set the y-axis label |
|
Set the y-axis limits |
|
Set the y-axis limits |
Plotter classes:
|
Plotter for making bar plots |
|
Base plotter for 2-dimensional plots |
|
Base plotter for vector plots |
|
Base plotter for combined 2-dimensional scalar and vector plot |
|
Combined 2D plotter and vector plotter |
|
A plotter to visualize the density of points in a 2-dimensional grid |
|
|
|
Plotter for simple one-dimensional line plots |
|
Base plotter for combined 2-dimensional scalar field with any other plotter |
|
Base class for |
|
Plotter for visualizing 2-dimensional data. |
|
Base class for all simple plotters |
|
Plotter for visualizing 2-dimensional vector data |
|
Plotter for making violin plots |
|
Plotter class for x- and y-ticks and x- and y- ticklabels |
Functions:
|
Convert the given coordinate from radian to degree |
|
Create a function that can replace the |
|
Round to the next 0.5-value. |
- class psy_simple.plotters.AlternativeXCoord(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Use an alternative variable as x-coordinate
This formatoption let’s you specify another variable in the base dataset of the data array in case you want to use this as the x-coordinate instead of the raw data
Possible types
None – Use the default
str – The name of the variable to use in the base dataset
xarray.DataArray – An alternative variable with the same shape as the displayed array
Examples
To see the difference, we create a simple test dataset:
>>> import xarray as xr >>> import numpy as np >>> import psyplot.project as psy >>> ds = xr.Dataset({ ... 'temp': xr.Variable(('time', ), np.arange(5)), ... 'std': xr.Variable(('time', ), np.arange(5, 10))}) >>> ds <xarray.Dataset> Dimensions: (time: 5) Coordinates: * time (time) int64 0 1 2 3 4 Data variables: temp (time) int64 0 1 2 3 4 std (time) int64 5 6 7 8 9
If we create a plot with it, we get the
'time'
dimension on the x-axis:>>> plotter = psy.plot.lineplot(ds, name=['temp']).plotters[0] >>> plotter.plot_data[0].dims ('time',)
If we however set the
'coord'
keyword, we get:>>> plotter = psy.plot.lineplot( ... ds, name=['temp'], coord='std').plotters[0] >>> plotter.plot_data[0].dims ('std',)
and
'std'
is plotted on the x-axis.- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.str
.str
.int
.Bool.
Methods:
diff
(value)Checks whether the given value differs from what is currently set
get_alternative_coord
(da, i)Replace the coordinate for the data array at the given position
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)
- property data_iterator
- diff(value)[source]
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 = 'Alternative X-Variable'
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)
- replace_coord(i)[source]
Replace the coordinate for the data array at the given position
- Parameters
i (int) – The number of the data array in the raw data (if the raw data is not an interactive list, use 0)
Returns –
xarray.DataArray – The data array with the replaced coordinate
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- use_raw_data = True
Bool. If True, this Formatoption directly uses the raw_data, otherwise use the normal data
- class psy_simple.plotters.AlternativeXCoordPost(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.AlternativeXCoord
Use an alternative variable as x-coordinate
This formatoption let’s you specify another variable in the base dataset of the data array in case you want to use this as the x-coordinate instead of the raw data
Possible types
None – Use the default
str – The name of the variable to use in the base dataset
xarray.DataArray – An alternative variable with the same shape as the displayed array
Examples
To see the difference, we create a simple test dataset:
>>> import xarray as xr >>> import numpy as np >>> import psyplot.project as psy >>> ds = xr.Dataset({ ... 'temp': xr.Variable(('time', ), np.arange(5)), ... 'std': xr.Variable(('time', ), np.arange(5, 10))}) >>> ds <xarray.Dataset> Dimensions: (time: 5) Coordinates: * time (time) int64 0 1 2 3 4 Data variables: temp (time) int64 0 1 2 3 4 std (time) int64 5 6 7 8 9
If we create a plot with it, we get the
'time'
dimension on the x-axis:>>> plotter = psy.plot.lineplot(ds, name=['temp']).plotters[0] >>> plotter.plot_data[0].dims ('time',)
If we however set the
'coord'
keyword, we get:>>> plotter = psy.plot.lineplot( ... ds, name=['temp'], coord='std').plotters[0] >>> plotter.plot_data[0].dims ('std',)
and
'std'
is plotted on the x-axis.- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
Bool.
- use_raw_data = False
Bool. If True, this Formatoption directly uses the raw_data, otherwise use the normal data
- class psy_simple.plotters.ArrowSize(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Change the size of the arrows
Possible types
None – make no scaling
float – Factor scaling the size of the arrows
See also
arrowstyle
,linewidth
,density
,color
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.str
.plot Formatoption instance in the plotter
int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- dependencies = ['plot']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Size of the arrows'
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
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.ArrowStyle(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Change the style of the arrows
Possible types
str – Any arrow style string (see
FancyArrowPatch
)Notes
This formatoption only has an effect for stream plots
See also
arrowsize
,linewidth
,density
,color
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.str
.plot Formatoption instance in the plotter
int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- dependencies = ['plot']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Style of the arrows'
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
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.AxisColor(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.DictFormatoption
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'
).- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.str
.Return the current axis colors
Methods:
initialize_plot
(value)Method that is called when the plot is made the first time
update
(value)Method that is call to update the formatoption on the axes
- initialize_plot(value)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- name = 'Color of x- and y-axes'
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)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property value2pickle
Return the current axis colors
- class psy_simple.plotters.BarAlpha(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Specify the transparency (alpha)
Possible types
float – A value between 0 (opaque) and 1 invisible
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- name = 'Transparency of the bars'
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
- class psy_simple.plotters.BarPlot(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Choose how to make the bar plot
Possible types
None – Don’t make any plotting
‘bar’ – Create a usual bar plot with the bars side-by-side
‘stacked’ – Create stacked plot
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
alpha Formatoption instance in the plotter
categorical Formatoption instance in the plotter
list of str.
color Formatoption instance in the plotter
bool
or a callable.list of str.
str
.str
.bool
.The data that is shown to the user
int
.transpose Formatoption instance in the plotter
widths Formatoption instance in the plotter
Methods:
get_xys
(arr)remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
- property alpha
alpha Formatoption instance in the plotter
- property categorical
categorical Formatoption instance in the plotter
- children = ['color', 'transpose', 'alpha']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property color
color Formatoption instance in the plotter
- 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 = ['widths', 'categorical']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Bar plot type'
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
- property plotted_data
The data that is shown to the user
- priority = 20
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)
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- property transpose
transpose Formatoption instance in the plotter
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property widths
widths Formatoption instance in the plotter
- class psy_simple.plotters.BarPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.SimplePlotterBase
Plotter for making bar plots
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Miscallaneous formatoptions:
Specify the transparency (alpha)
The location of each bar
Draw a legend
Set the labels of the arrays in the legend
Make x- and y-axis symmetric
Change the ticksize of the ticklabels
Change the fontweight of the ticks
Specify the widths of the bars
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Switch x- and y-axes
Set the x-axis limits
Set the y-axis limits
Color coding formatoptions:
Set the color coding
Data manipulation formatoptions:
Use an alternative variable as x-coordinate
Label formatoptions:
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
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:
Choose how to make the bar plot
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoptionAxis tick formatoptions:
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
- alpha
Specify the transparency (alpha)
Possible types
float – A value between 0 (opaque) and 1 invisible
- 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
- categorical
The location of each bar
Possible types
None – If None, use a categorical plotting if the widths are
'equal'
, otherwise, notbool – If True, use a categorical plotting
See also
- color
Set the color coding
This formatoptions sets the color of the lines, bars, etc.
Possible types
None – to use the axes color_cycle
iterable – (e.g. list) to specify the colors manually
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 – to automatically choose the colors according to the number of lines, etc. from the given colormap
- coord
Use an alternative variable as x-coordinate
This formatoption let’s you specify another variable in the base dataset of the data array in case you want to use this as the x-coordinate instead of the raw data
Possible types
None – Use the default
str – The name of the variable to use in the base dataset
xarray.DataArray – An alternative variable with the same shape as the displayed array
Examples
To see the difference, we create a simple test dataset:
>>> import xarray as xr >>> import numpy as np >>> import psyplot.project as psy >>> ds = xr.Dataset({ ... 'temp': xr.Variable(('time', ), np.arange(5)), ... 'std': xr.Variable(('time', ), np.arange(5, 10))}) >>> ds <xarray.Dataset> Dimensions: (time: 5) Coordinates: * time (time) int64 0 1 2 3 4 Data variables: temp (time) int64 0 1 2 3 4 std (time) int64 5 6 7 8 9
If we create a plot with it, we get the
'time'
dimension on the x-axis:>>> plotter = psy.plot.lineplot(ds, name=['temp']).plotters[0] >>> plotter.plot_data[0].dims ('time',)
If we however set the
'coord'
keyword, we get:>>> plotter = psy.plot.lineplot( ... ds, name=['temp'], coord='std').plotters[0] >>> plotter.plot_data[0].dims ('std',)
and
'std'
is plotted on the x-axis.
- 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()
functionNotes
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'
).
- 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
- legend
Draw a legend
This formatoption determines where and if to draw the legend. It uses the
labels
formatoption to determine the labels.Possible types
bool – Draw a legend or not
str or int – Specifies where to plot the legend (i.e. the location)
dict – Give the keywords for the
matplotlib.pyplot.legend()
function
See also
labels
- legendlabels
Set the labels of the arrays in the legend
This formatoption specifies the labels for each array in the legend. 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 – A single string that shall be used for all arrays.
list of str – Same as a single string but specified for each array
See also
- 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
- 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
- plot
Choose how to make the bar plot
Possible types
None – Don’t make any plotting
‘bar’ – Create a usual bar plot with the bars side-by-side
‘stacked’ – Create stacked 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- widths
Specify the widths of the bars
Possible types
‘equal’ – Each bar will have the same width (the default)
‘data’ – Each bar will have the width as specified by the boundaries
float – The width for each bar
See also
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.BarWidths(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Specify the widths of the bars
Possible types
‘equal’ – Each bar will have the same width (the default)
‘data’ – Each bar will have the width as specified by the boundaries
float – The width for each bar
See also
categorical
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- name = 'Width of the bars'
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
- class psy_simple.plotters.BarXTickLabels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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 integersarray – An array of strings to use for the ticklabels
See also
xticks
,ticksize
,tickweight
,xtickprops
,yticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
categorical Formatoption instance in the plotter
list of str.
plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xticks Formatoption instance in the plotter
yticklabels Formatoption instance in the plotter
Methods:
- property categorical
categorical Formatoption instance in the plotter
- dependencies = ['transpose', 'xticks', 'yticklabels', 'plot', 'categorical']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xticks
xticks Formatoption instance in the plotter
- property yticklabels
yticklabels Formatoption instance in the plotter
- class psy_simple.plotters.BarXTicks(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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 necessarydict – 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
xticklabels
,ticksize
,tickweight
,xtickprops
,yticks
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
categorical Formatoption instance in the plotter
list of str.
list of str.
plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xlim Formatoption instance in the plotter
yticks Formatoption instance in the plotter
Methods:
Sets the default locator that is used for updating to None or int
update
(value)Method that is call to update the formatoption on the axes
- property array
The numpy array of the data
- property categorical
categorical Formatoption instance in the plotter
- connections = ['xlim']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- dependencies = ['transpose', 'plot', 'plot', 'categorical']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- set_default_locators()[source]
Sets the default locator that is used for updating to None or int
- Parameters
which ({None, 'minor', 'major'}) – Specify which locator shall be set
- property transpose
transpose Formatoption instance in the plotter
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property xlim
xlim Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.BarXlabel(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
transpose Formatoption instance in the plotter
Xlabel is modified by the pandas plot routine, therefore we update it after each plot
ylabel Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- update_after_plot = True
Xlabel is modified by the pandas plot routine, therefore we update it after each plot
- property ylabel
ylabel Formatoption instance in the plotter
- class psy_simple.plotters.BarXlim(*args, **kwargs)[source]
Bases:
psy_simple.plotters.ViolinXlim
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
categorical Formatoption instance in the plotter
list of str.
plot Formatoption instance in the plotter
sym_lims Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xticks Formatoption instance in the plotter
ylim Formatoption instance in the plotter
- property array
The numpy array of the data
- property categorical
categorical Formatoption instance in the plotter
- dependencies = ['xticks', 'categorical']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- property sym_lims
sym_lims Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xticks
xticks Formatoption instance in the plotter
- property ylim
ylim Formatoption instance in the plotter
- class psy_simple.plotters.BarYTickLabels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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 integersarray – An array of strings to use for the ticklabels
See also
yticks
,ticksize
,tickweight
,ytickprops
,xticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
categorical Formatoption instance in the plotter
list of str.
plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
yticks Formatoption instance in the plotter
Methods:
- property categorical
categorical Formatoption instance in the plotter
- dependencies = ['transpose', 'yticks', 'plot', 'categorical']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.BarYTicks(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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 necessarydict – 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).
See also
yticklabels
,ticksize
,tickweight
,ytickprops
xticks
for possible examples
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
categorical Formatoption instance in the plotter
list of str.
list of str.
plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
ylim Formatoption instance in the plotter
Methods:
Sets the default locator that is used for updating to None or int
update
(value)Method that is call to update the formatoption on the axes
- property array
The numpy array of the data
- property categorical
categorical Formatoption instance in the plotter
- connections = ['ylim']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- dependencies = ['transpose', 'plot', 'plot', 'categorical']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- set_default_locators()[source]
Sets the default locator that is used for updating to None or int
- Parameters
which ({None, 'minor', 'major'}) – Specify which locator shall be set
- property transpose
transpose Formatoption instance in the plotter
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property ylim
ylim Formatoption instance in the plotter
- class psy_simple.plotters.BarYlabel(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
transpose Formatoption instance in the plotter
Ylabel is modified by the pandas plot routine, therefore we update it after each plot
- property transpose
transpose Formatoption instance in the plotter
- update_after_plot = True
Ylabel is modified by the pandas plot routine, therefore we update it after each plot
- class psy_simple.plotters.BarYlim(*args, **kwargs)[source]
Bases:
psy_simple.plotters.ViolinYlim
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
categorical Formatoption instance in the plotter
list of str.
plot Formatoption instance in the plotter
sym_lims Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xlim Formatoption instance in the plotter
yticks Formatoption instance in the plotter
- property array
The numpy array of the data
- property categorical
categorical Formatoption instance in the plotter
- dependencies = ['yticks', 'categorical']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- property sym_lims
sym_lims Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xlim
xlim Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.Base2D(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psyplot.plotter.Plotter
Base plotter for 2-dimensional plots
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
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
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
Axis tick formatoptions:
Specify the colorbar ticklabels
Specify the tick locations of the colorbar
Miscallaneous formatoptions:
Show the grid of the data
Mask the datagrid where the array is NaN
Attributes:
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoption- 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 necessarydict – 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
- 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 integersarray – 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()
functionSee 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 necessarydict – 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
- 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
- plot = None
- 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
- class psy_simple.plotters.BaseVectorPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.Base2D
Base plotter for vector plots
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Attributes:
Vector plot formatoptions:
Change the size of the arrows
Change the style of the arrows
Change the density of the arrows
Color coding formatoptions:
Specify the boundaries of the vector colorbar
Specify the position of the vector plot colorbars
Specify the spacing of the bounds in the colorbar
Specify the color map
Set the color for the arrows
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
Methods:
check_data
(name, dims, is_unstructured)A validation method for the data shape
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
Axis tick formatoptions:
Specify the colorbar ticklabels
Specify the tick locations of the vector colorbar
Miscallaneous formatoptions:
Change the linewidth of the arrows
Mask the datagrid where the array is NaN
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoption- allowed_dims = 3
- arrowsize
Change the size of the arrows
Possible types
None – make no scaling
float – Factor scaling the size of the arrows
See also
- arrowstyle
Change the style of the arrows
Possible types
str – Any arrow style string (see
FancyArrowPatch
)Notes
This formatoption only has an effect for stream plots
- bounds
Specify the boundaries of the vector 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 necessarydict – 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 vector plot 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
- 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
- classmethod check_data(name, dims, is_unstructured)[source]
A validation method for the data shape
- Parameters
name (str or list of str) – The variable names (two variables for the array or one if the dims are one greater)
dims (list with length 1 or list of lists with length 1) – The dimension of the arrays. Only 2D-Arrays are allowed (or 1-D if the array is unstructured)
is_unstructured (bool or list of bool) – True if the corresponding array is unstructured.
- Returns
list of bool or None – True, if everything is okay, False in case of a serious error, None if it is intermediate. Each object in this list corresponds to one in the given name
list of str – The message giving more information on the reason. Each object in this list corresponds to one in the given name
- 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
- color
Set the color for the arrows
This formatoption can be used to set a single color for the vectors or define the color coding
Possible types
float – Determines the greyness
color – Defines the same color for all arrows. The string can be either a html hex string (e.g. ‘#eeefff’), a single letter (e.g. ‘b’: blue, ‘g’: green, ‘r’: red, ‘c’: cyan, ‘m’: magenta, ‘y’: yellow, ‘k’: black, ‘w’: white) or any other color
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
2D-array – The values determine the color for each plotted arrow. Note that the shape has to match the one of u and v.
See also
- 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 integersarray – 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()
functionSee also
cticksize
,ctickweight
,cticklabels
,cticks
,vcticksize
,vctickweight
,vcticklabels
,vcticks
- cticks
Specify the tick locations of the vector 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 necessarydict – 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
cticklabels
,vcticklabels
- 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
- density
Change the density of the arrows
Possible types
float – Scales the density of the arrows in x- and y-direction (1.0 means no scaling)
tuple (x, y) – Defines the scaling in x- and y-direction manually
Notes
quiver plots do not support density scaling
- 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
- linewidth
Change the linewidth of the arrows
Possible types
float – give the linewidth explicitly
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
tuple (string, float) – string may be one of the above strings, float may be a scaling factor
2D-array – The values determine the linewidth for each plotted arrow. Note that the shape has to match the one of u and v.
See also
- 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
- 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
- class psy_simple.plotters.Bounds(*args, **kwargs)[source]
Bases:
psy_simple.plotters.DataTicksCalculator
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 necessarydict – 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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
cmap Formatoption instance in the plotter
list of str.
str
.str
.int
.The normalization instance
Methods:
get_fmt_widget
(parent, project)Open a
psy_simple.widget.CMapFmtWidget
update
(value)Method that is call to update the formatoption on the axes
- property cbar
cbar Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- connections = ['cmap', 'cbar']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- name = 'Boundaries of the color map'
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 = 20
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)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
The normalization instance
- class psy_simple.plotters.CLabel(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.base.TextBase
,psyplot.plotter.Formatoption
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
clabelsize
,clabelweight
,clabelprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
list of str.
bool
or a callable.list of str.
str
.str
.plot Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- axis_locations = {'b': 'x', 'fb': 'x', 'fl': 'y', 'fr': 'y', 'ft': 'x', 'l': 'y', 'r': 'y', 'sh': 'x', 'sv': 'y', 't': 'x'}
- property cbar
cbar Formatoption instance in the plotter
- children = ['plot']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- 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 = ['cbar']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Colorbar label'
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
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.CMap(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bounds Formatoption instance in the plotter
cbar Formatoption instance in the plotter
list of str.
str
.str
.int
.Methods:
get_cmap
([arr, cmap, N])Get the
matplotlib.colors.Colormap
for plottingget_fmt_widget
(parent, project)Open a
psy_simple.widget.CMapFmtWidget
update
(value)Method that is call to update the formatoption on the axes
- property bounds
bounds Formatoption instance in the plotter
- property cbar
cbar Formatoption instance in the plotter
- connections = ['bounds', 'cbar']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- get_cmap(arr=None, cmap=None, N=None)[source]
Get the
matplotlib.colors.Colormap
for plotting- Parameters
arr (np.ndarray) – The array to plot
cmap (str or matplotlib.colors.Colormap) – The colormap to use. If None, the
value
of this formatoption is usedN (int) – The number of colors in the colormap. If None, the norm of the
bounds
formatoption is used and, if necessary, the given array arr
- Returns
The colormap returned by
psy_simple.colors.get_cmap()
- Return type
- name = 'Colormap'
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
- class psy_simple.plotters.CTickLabels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.CbarOptions
,psy_simple.plotters.TickLabelsBase
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 integersarray – An array of strings to use for the ticklabels
See also
cticks
,cticksize
,ctickweight
,ctickprops
,vcticks
,vcticksize
,vctickweight
,vctickprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
Default locator of the axis of the colorbars
str
.plot Formatoption instance in the plotter
Methods:
Sets the default formatters that is used for updating to None
set_formatter
(formatter)Sets a given formatter
- property cbar
cbar Formatoption instance in the plotter
- property default_formatters
Default locator of the axis of the colorbars
- name = 'Colorbar ticklabels'
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
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.CTickProps(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.CbarOptions
,psy_simple.plotters.TickPropsBase
Specify the font properties of the colorbar ticklabels
Possible types
dict – Items may be anything of the
matplotlib.pyplot.tick_params()
functionSee also
cticksize
,ctickweight
,cticklabels
,cticks
,vcticksize
,vctickweight
,vcticklabels
,vcticks
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
list of str.
str
.str
.plot Formatoption instance in the plotter
Methods:
update_axis
(value)- property cbar
cbar Formatoption instance in the plotter
- children = ['plot']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- name = 'Font properties of the colorbar ticklabels'
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
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.CTickSize(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.CbarOptions
,psy_simple.plotters.TickSizeBase
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
ctickprops Formatoption instance in the plotter
list of str.
str
.str
.plot Formatoption instance in the plotter
- property cbar
cbar Formatoption instance in the plotter
- property ctickprops
ctickprops Formatoption instance in the plotter
- dependencies = ['cbar', 'ctickprops']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Font size of the colorbar ticklabels'
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
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.CTickWeight(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.CbarOptions
,psy_simple.plotters.TickWeightBase
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
ctickprops Formatoption instance in the plotter
list of str.
str
.str
.plot Formatoption instance in the plotter
- property cbar
cbar Formatoption instance in the plotter
- property ctickprops
ctickprops Formatoption instance in the plotter
- dependencies = ['cbar', 'ctickprops']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Font weight of the colorbar ticklabels'
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
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.CTicks(*args, **kwargs)[source]
Bases:
psy_simple.plotters.CbarOptions
,psy_simple.plotters.TicksBase
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 necessarydict – 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
cticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bounds Formatoption instance in the plotter
cbar Formatoption instance in the plotter
cmap Formatoption instance in the plotter
list of str.
Default locator of the axis of the colorbars
list of str.
str
.plot Formatoption instance in the plotter
Methods:
get_fmt_widget
(parent, project)Open a
psy_simple.widget.CMapFmtWidget
set_default_locators
(*args, **kwargs)Sets the default locator that is used for updating to None or int
set_ticks
(value)update
(value)Method that is call to update the formatoption on the axes
update_axis
(value)- property bounds
bounds Formatoption instance in the plotter
- property cbar
cbar Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- connections = ['cmap']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- property default_locator
Default locator of the axis of the colorbars
- dependencies = ['cbar', 'bounds']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Colorbar ticks'
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
- property plot
plot Formatoption instance in the plotter
- set_default_locators(*args, **kwargs)[source]
Sets the default locator that is used for updating to None or int
- Parameters
which ({None, 'minor', 'major'}) – Specify which locator shall be set
- class psy_simple.plotters.CategoricalBars(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
The location of each bar
Possible types
None – If None, use a categorical plotting if the widths are
'equal'
, otherwise, notbool – If True, use a categorical plotting
See also
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.int
.widths Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- dependencies = ['widths']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Categorical or non-categorical plotting'
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 = 20
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)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property widths
widths Formatoption instance in the plotter
- class psy_simple.plotters.Cbar(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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')
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.other_cbars (list of str) – List of other colorbar formatoption keys (necessary for a sufficient resizing of the axes)
Attributes:
bounds Formatoption instance in the plotter
cbarspacing Formatoption instance in the plotter
cmap Formatoption instance in the plotter
list of str.
extend Formatoption instance in the plotter
str
.dict
key word arguments that are passed to the initialization of a new instance when accessed from the descriptorlevels Formatoption instance in the plotter
str
.plot Formatoption instance in the plotter
int
.Those colorbar positions that are directly at the axes
Methods:
draw_colorbar
(pos)Finish the update, initialization and sharing process
initialize_plot
(value)Method that is called when the plot is made the first time
remove
([positions])Method to remove the effects of this formatoption
set_label_pos
(pos)update
(value)Updates the colorbar
update_colorbar
(pos)- property bounds
bounds Formatoption instance in the plotter
- property cbarspacing
cbarspacing Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- dependencies = ['plot', 'cmap', 'bounds', 'extend', 'cbarspacing', 'levels']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property extend
extend Formatoption instance in the plotter
- figure_positions = {'b', 'fb', 'fl', 'fr', 'ft', 'l', 'r', 't'}
- finish_update()[source]
Finish the update, initialization and sharing process
This function is called at the end of the
Plotter.start_update()
,Plotter.initialize_plot()
or thePlotter.share()
methods.
- property init_kwargs
dict
key word arguments that are passed to the initialization of a new instance when accessed from the descriptor
- initialize_plot(value)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- property levels
levels Formatoption instance in the plotter
- name = 'Position of the colorbar'
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
- original_position = None
- property plot
plot Formatoption instance in the plotter
- priority = 10.1
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)
- remove(positions='all')[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- update(value)[source]
Updates the colorbar
- Parameters
value – The value to update (see possible types)
no_fig_cbars – Does not update the colorbars that are not in the axes of this plot
Those colorbar positions that are directly at the axes
- class psy_simple.plotters.CbarOptions(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Base class for colorbar formatoptions
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
axis of the colorbar with the ticks.
cbar Formatoption instance in the plotter
list of str.
The data that is plotted
list of str.
plot Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- property axis
axis of the colorbar with the ticks. Will be overwritten during update process.
- axis_locations = {'b': 'x', 'fb': 'x', 'fl': 'y', 'fr': 'y', 'ft': 'x', 'l': 'y', 'r': 'y', 'sh': 'x', 'sv': 'y', 't': 'x'}
- property axisname
- property cbar
cbar Formatoption instance in the plotter
- children = ['plot']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property colorbar
- property data
The data that is plotted
- dependencies = ['cbar']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- which = 'major'
- class psy_simple.plotters.CbarSpacing(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
list of str.
str
.str
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- property cbar
cbar Formatoption instance in the plotter
- connections = ['cbar']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- class psy_simple.plotters.CombinedBase(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.ScalarCombinedBase
Base plotter for combined 2-dimensional scalar and vector plot
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Vector plot formatoptions:
Change the size of the arrows
Change the style of the arrows
Color coding formatoptions:
Specify the boundaries of the colorbar
Specify the position of the colorbars
Set the color for the arrows
Specify the boundaries of the vector colorbar
Specify the position of the vector plot 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
Methods:
check_data
(name, dims, is_unstructured)A validation method for the data shape
Axis tick formatoptions:
Specify the tick locations of the colorbar
Specify the colorbar ticklabels
Specify the tick locations of the vector colorbar
Miscallaneous formatoptions:
Change the linewidth of the arrows
Masking formatoptions:
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
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoptionLabel formatoptions:
Show the colorbar label of the vector plot
Properties of the Vector colorbar label
Set the size of the Vector colorbar label
Set the fontweight of the Vector colorbar label
- arrowsize
Change the size of the arrows
Possible types
None – make no scaling
float – Factor scaling the size of the arrows
See also
arrowstyle
,linewidth
,density
,color
- arrowstyle
Change the style of the arrows
Possible types
str – Any arrow style string (see
FancyArrowPatch
)Notes
This formatoption only has an effect for stream plots
- 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 necessarydict – 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')
- classmethod check_data(name, dims, is_unstructured)[source]
A validation method for the data shape
- Parameters
name (list of str with length 2) – The variable names (one for the first, two for the second array)
dims (list with length 2 of lists with length 1) – The dimension of the arrays. Only 2D-Arrays are allowed (or 1-D if an array is unstructured)
is_unstructured (bool or list of bool) – True if the corresponding array is unstructured.
- Returns
list of bool or None – True, if everything is okay, False in case of a serious error, None if it is intermediate. Each object in this list corresponds to one in the given name
list of str – The message giving more information on the reason. Each object in this list corresponds to one in the given name
- color
Set the color for the arrows
This formatoption can be used to set a single color for the vectors or define the color coding
Possible types
float – Determines the greyness
color – Defines the same color for all arrows. The string can be either a html hex string (e.g. ‘#eeefff’), a single letter (e.g. ‘b’: blue, ‘g’: green, ‘r’: red, ‘c’: cyan, ‘m’: magenta, ‘y’: yellow, ‘k’: black, ‘w’: white) or any other color
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
2D-array – The values determine the color for each plotted arrow. Note that the shape has to match the one of u and v.
See also
arrowsize
,arrowstyle
,density
,linewidth
- 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 necessarydict – 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
cticklabels
- linewidth
Change the linewidth of the arrows
Possible types
float – give the linewidth explicitly
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
tuple (string, float) – string may be one of the above strings, float may be a scaling factor
2D-array – The values determine the linewidth for each plotted arrow. Note that the shape has to match the one of u and v.
See also
arrowsize
,arrowstyle
,density
,color
- 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
- 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
- vbounds
Specify the boundaries of the vector 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 necessarydict – 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
- vcbar
Specify the position of the vector plot 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
- vcbarspacing
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
- vclabel
Show the colorbar label of the vector plot
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
- vclabelprops
Properties of the Vector colorbar label
Specify the font properties of the figure title manually.
Possible types
dict – Items may be any valid text property
See also
- vclabelsize
Set the size of the Vector 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
- vclabelweight
Set the fontweight of the Vector 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
- vcmap
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
- vcticklabels
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 integersarray – An array of strings to use for the ticklabels
See also
cticks
,cticksize
,ctickweight
,ctickprops
,vcticks
,vcticksize
,vctickweight
,vctickprops
- vctickprops
Specify the font properties of the colorbar ticklabels
Possible types
dict – Items may be anything of the
matplotlib.pyplot.tick_params()
functionSee also
cticksize
,ctickweight
,cticklabels
,cticks
,vcticksize
,vctickweight
,vcticklabels
,vcticks
- vcticks
Specify the tick locations of the vector 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 necessarydict – 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
cticklabels
,vcticklabels
- vcticksize
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
- vctickweight
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
- class psy_simple.plotters.CombinedSimplePlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.CombinedBase
,psy_simple.plotters.Simple2DPlotter
,psy_simple.plotters.SimpleVectorPlotter
Combined 2D plotter and vector plotter
See also
psyplot.plotter.maps.CombinedPlotter
for visualizing the data on a map
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Vector plot formatoptions:
Change the size of the arrows
Change the style of the arrows
Change the density of the arrows
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Switch x- and y-axes
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
Set the color for the arrows
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
Specify the boundaries of the vector colorbar
Specify the position of the vector plot 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
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
Show the colorbar label of the vector plot
Properties of the Vector colorbar label
Set the size of the Vector colorbar label
Set the fontweight of the Vector colorbar label
Set the x-axis label
Set the y-axis label
Axis tick formatoptions:
Specify the colorbar ticklabels
Specify the tick locations of the colorbar
Specify the colorbar ticklabels
Specify the tick locations of the vector 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
Miscallaneous formatoptions:
Interpolate grid cell boundaries for 2D plots
Change the linewidth of the arrows
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
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:
Choose how to visualize a 2-dimensional scalar data field
Choose the vector plot type
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoption- arrowsize
Change the size of the arrows
Possible types
None – make no scaling
float – Factor scaling the size of the arrows
See also
- arrowstyle
Change the style of the arrows
Possible types
str – Any arrow style string (see
FancyArrowPatch
)Notes
This formatoption only has an effect for stream plots
- 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 necessarydict – 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
- color
Set the color for the arrows
This formatoption can be used to set a single color for the vectors or define the color coding
Possible types
float – Determines the greyness
color – Defines the same color for all arrows. The string can be either a html hex string (e.g. ‘#eeefff’), a single letter (e.g. ‘b’: blue, ‘g’: green, ‘r’: red, ‘c’: cyan, ‘m’: magenta, ‘y’: yellow, ‘k’: black, ‘w’: white) or any other color
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
2D-array – The values determine the color for each plotted arrow. Note that the shape has to match the one of u and v.
See also
- 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 integersarray – 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()
functionSee 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 necessarydict – 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
- density
Change the density of the arrows
Possible types
float – Scales the density of the arrows in x- and y-direction (1.0 means no scaling)
tuple (x, y) – Defines the scaling in x- and y-direction manually
Notes
quiver plots do not support density scaling
- 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()
functionNotes
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 11numeric 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 necessarydict – 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]
.
- linewidth
Change the linewidth of the arrows
Possible types
float – give the linewidth explicitly
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
tuple (string, float) – string may be one of the above strings, float may be a scaling factor
2D-array – The values determine the linewidth for each plotted arrow. Note that the shape has to match the one of u and v.
See also
- 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
Choose how to visualize a 2-dimensional scalar data field
Possible types
None – Don’t make any plotting
‘mesh’ – Use the
matplotlib.pyplot.pcolormesh()
function to make the plot or thematplotlib.pyplot.tripcolor()
for an unstructered grid‘poly’ – Draw each polygon indivually. This method is used by default for unstructured grids. If there are no grid cell boundaries in the dataset, we will interpolate them
‘contourf’ – Make a filled contour plot using the
matplotlib.pyplot.contourf()
function. The levels for the contour plot are controlled by thelevels
formatoption‘contour’ – Same a
'contourf'
, but does not make a filled contour plot, only lines.
- 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- vbounds
Specify the boundaries of the vector 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 necessarydict – 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
- vcbar
Specify the position of the vector plot 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
- vcbarspacing
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
- vclabel
Show the colorbar label of the vector plot
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
- vclabelprops
Properties of the Vector colorbar label
Specify the font properties of the figure title manually.
Possible types
dict – Items may be any valid text property
See also
- vclabelsize
Set the size of the Vector 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
- vclabelweight
Set the fontweight of the Vector 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
- vcmap
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
- vcticklabels
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 integersarray – An array of strings to use for the ticklabels
See also
cticks
,cticksize
,ctickweight
,ctickprops
,vcticks
,vcticksize
,vctickweight
,vctickprops
- vctickprops
Specify the font properties of the colorbar ticklabels
Possible types
dict – Items may be anything of the
matplotlib.pyplot.tick_params()
functionSee also
cticksize
,ctickweight
,cticklabels
,cticks
,vcticksize
,vctickweight
,vcticklabels
,vcticks
- vcticks
Specify the tick locations of the vector 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 necessarydict – 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
- vcticksize
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
- vctickweight
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
- vplot
Choose the vector plot type
Possible types
str – Plot types can be either
- quiver
to make a quiver plot
- stream
to make a stream plot
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.CombinedVectorPlot(*args, **kwargs)[source]
Bases:
psy_simple.plotters.VectorPlot
Choose the vector plot type
Possible types
str – Plot types can be either
- quiver
to make a quiver plot
- stream
to make a stream plot
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
arrowsize Formatoption instance in the plotter
arrowstyle Formatoption instance in the plotter
bounds Formatoption instance in the plotter
cmap Formatoption instance in the plotter
color Formatoption instance in the plotter
bool
or a callable.density Formatoption instance in the plotter
linewidth Formatoption instance in the plotter
transform Formatoption instance in the plotter
transpose Formatoption instance in the plotter
Methods:
update
(*args, **kwargs)Method that is call to update the formatoption on the axes
- property arrowsize
arrowsize Formatoption instance in the plotter
- property arrowstyle
arrowstyle Formatoption instance in the plotter
- property bounds
bounds Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- property color
color Formatoption instance in the plotter
- 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)
- property density
density Formatoption instance in the plotter
- property linewidth
linewidth Formatoption instance in the plotter
- property transform
transform Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.ContourLevels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.Bounds
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 11numeric 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 necessarydict – 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]
.
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
cbounds Formatoption instance in the plotter
cmap Formatoption instance in the plotter
list of str.
str
.int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- property cbar
cbar Formatoption instance in the plotter
- property cbounds
cbounds Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- dependencies = ['cbounds']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Levels for the filled contour plot'
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
- class psy_simple.plotters.DataGrid(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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
- Parameters
%(Formatoption.parameters)s –
Attributes:
The unstructured x-boundaries with shape (N, m) where m > 2
The unstructured y-boundaries with shape (N, m) where m > 2
list of str.
list of str.
list of str.
mask_datagrid Formatoption instance in the plotter
str
.plot Formatoption instance in the plotter
transform Formatoption instance in the plotter
Boundaries of the x-coordinate
The x coordinate
xarray.Variable
Boundaries of the y-coordinate
The y coordinate
xarray.Variable
Methods:
remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
- property cell_nodes_x
The unstructured x-boundaries with shape (N, m) where m > 2
- property cell_nodes_y
The unstructured y-boundaries with shape (N, m) where m > 2
- children = ['transform']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- connections = ['plot']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- dependencies = ['mask_datagrid']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property mask_datagrid
mask_datagrid Formatoption instance in the plotter
- name = 'Grid of the 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
- property plot
plot Formatoption instance in the plotter
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- property transform
transform Formatoption instance in the plotter
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property xbounds
Boundaries of the x-coordinate
- property xcoord
The x coordinate
xarray.Variable
- property ybounds
Boundaries of the y-coordinate
- property ycoord
The y coordinate
xarray.Variable
- class psy_simple.plotters.DataPrecision(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Set the precision of the data
This formatoption can be used to specify the precision of the data which then will be the minimal bin width of the 2D histogram or the bandwith of the kernel size (if the
density
formatoption is set to'kde'
)Possible types
float – If 0, this formatoption has no effect at all. Otherwise it is assumed to be the precision of the data
str – One of
{'scott' | 'silverman'}
. This uses the statsmodels package to estimate the bandwidth of the data that is then used in the histogram or KDE plot
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
bool
or a callable.density Formatoption instance in the plotter
list of str.
str
.str
.int
.xrange Formatoption instance in the plotter
yrange Formatoption instance in the plotter
Methods:
estimate_bw
(method, values[, data_range])update
(value)Method that is call to update the formatoption on the axes
- connections = ['density']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- 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)
- property density
density Formatoption instance in the plotter
- dependencies = ['xrange', 'yrange']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Precision of the visualized 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)
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property xrange
xrange Formatoption instance in the plotter
- property yrange
yrange Formatoption instance in the plotter
- class psy_simple.plotters.DataTicksCalculator(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Abstract base formatoption to calculate ticks and bounds from the data
Possible types
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 necessarydict – 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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
bool
or a callable.The full array of this and the shared data
- property array
The numpy array of the data
- 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)
- property full_array
The full array of this and the shared data
- class psy_simple.plotters.Density(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Change the density of the arrows
Possible types
float – Scales the density of the arrows in x- and y-direction (1.0 means no scaling)
tuple (x, y) – Defines the scaling in x- and y-direction manually
Notes
quiver plots do not support density scaling
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.list of str.
str
.str
.plot Formatoption instance in the plotter
int
.Methods:
remove
([plot_type])Method to remove the effects of this formatoption
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 = ['plot']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Density of the arrows'
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
- property plot
plot Formatoption instance in the plotter
- priority = 20
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)
- remove(plot_type=None)[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- class psy_simple.plotters.DensityPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.Simple2DPlotter
A plotter to visualize the density of points in a 2-dimensional grid
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Attributes:
The number of allowed dimensions in the for the visualization.
The number variables that one data array visualized by this plotter might have.
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Switch x- and y-axes
Set the x-axis limits
Set the y-axis limits
Data manipulation formatoptions:
Specify the bins of the 2D-Histogramm
Use an alternative variable as x-coordinate
Specify the method to calculate the density
Specify the normalization of the histogram
Set the precision of the data
Specify the range of the histogram for the x-dimension
Specify the range of the histogram for the x-dimension
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
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
Miscallaneous formatoptions:
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
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 = 1
The number of allowed dimensions in the for the visualization. If the array is unstructured, one dimension will be subtracted
- allowed_vars = 1
The number variables that one data array visualized by this plotter might have.
- 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
- bins
Specify the bins of the 2D-Histogramm
This formatoption can be used to specify, how many bins to use. In other words, it determines the grid size of the resulting histogram or kde plot. If however you also set the
precision
formatoption keyword then the minimum of precision and the bins specified here will be used.Possible types
- 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 necessarydict – 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
Use an alternative variable as x-coordinate
This formatoption let’s you specify another variable in the base dataset of the data array in case you want to use this as the x-coordinate instead of the raw data
Possible types
None – Use the default
str – The name of the variable to use in the base dataset
xarray.DataArray – An alternative variable with the same shape as the displayed array
Examples
To see the difference, we create a simple test dataset:
>>> import xarray as xr >>> import numpy as np >>> import psyplot.project as psy >>> ds = xr.Dataset({ ... 'temp': xr.Variable(('time', ), np.arange(5)), ... 'std': xr.Variable(('time', ), np.arange(5, 10))}) >>> ds <xarray.Dataset> Dimensions: (time: 5) Coordinates: * time (time) int64 0 1 2 3 4 Data variables: temp (time) int64 0 1 2 3 4 std (time) int64 5 6 7 8 9
If we create a plot with it, we get the
'time'
dimension on the x-axis:>>> plotter = psy.plot.lineplot(ds, name=['temp']).plotters[0] >>> plotter.plot_data[0].dims ('time',)
If we however set the
'coord'
keyword, we get:>>> plotter = psy.plot.lineplot( ... ds, name=['temp'], coord='std').plotters[0] >>> plotter.plot_data[0].dims ('std',)
and
'std'
is plotted on the x-axis.
- 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 integersarray – 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()
functionSee 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 necessarydict – 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
- density
Specify the method to calculate the density
Possible types
str – One of the following strings are possible
- hist
Make a 2D-histogram. The normalization is controlled by the
normed
formatoption- kde
Fit a bivariate kernel density estimate to the data. Note that this choice requires pythons [statsmodels] module to be installed
References
- statsmodels
- 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()
functionNotes
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 11numeric 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 necessarydict – 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.
- normed
Specify the normalization of the histogram
This formatoption can be used to normalize the histogram. It has no effect if the
density
formatoption is set to'kde'
Possible types
None – Do not make any normalization
str – One of
- counts
To make the normalization based on the total number counts
- area
To make the normalization basen on the total number of counts and area (the default behaviour of
numpy.histogram2d()
)- x, col, column or columns
To normalize every column
- y, row or rows
To normalize every row
See also
- 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
- precision
Set the precision of the data
This formatoption can be used to specify the precision of the data which then will be the minimal bin width of the 2D histogram or the bandwith of the kernel size (if the
density
formatoption is set to'kde'
)Possible types
float – If 0, this formatoption has no effect at all. Otherwise it is assumed to be the precision of the data
str – One of
{'scott' | 'silverman'}
. This uses the statsmodels package to estimate the bandwidth of the data that is then used in the histogram or KDE plot
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- 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
- xrange
Specify the range of the histogram for the x-dimension
This formatoption specifies the minimum and maximum of the histogram in the x-dimension
Possible types
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
Notes
This formatoption always acts on the coordinate, no matter what the value of the
transpose
formatoption isSee also
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrange
Specify the range of the histogram for the x-dimension
This formatoption specifies the minimum and maximum of the histogram in the x-dimension
Possible types
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
Notes
This formatoption always acts on the DataArray, no matter what the value of the
transpose
formatoption isSee also
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.DtTicksBase(*args, **kwargs)[source]
Bases:
psy_simple.plotters.TicksBase
,psy_simple.plotters.TicksManager
Abstract base class for x- and y-tick formatoptions
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 necessarydict – 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).
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The np.unique
data
as datetime objectsplot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- property dtdata
The np.unique
data
as datetime objects
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.ErrorAlpha(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Set the alpha value for the error range
This formatoption can be used to set the alpha value (opacity) for the
error
formatoptionPossible types
float – A float between 0 and 1
See also
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
error Formatoption instance in the plotter
str
.str
.int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- connections = ['error']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- property error
error Formatoption instance in the plotter
- name = 'Alpha value of the error range'
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
- class psy_simple.plotters.ErrorCalculator(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Calculation of the error
This formatoption is used to calculate the error range.
Possible types
None – Do not calculate any error range
float – A float between 0 and 50. This will represent the distance from the median (i.e. the 50th percentile). A value of 45 will hence correspond to the 5th and 95th percentile
list of 2 floats between 0 and 100 – Two floats where the first corresponds to the minimum and the second to the maximum percentile
str – A string with ‘std’ in it. Then we will use the standard deviation. Any number in this string, e.g. ‘3.5std’ will serve as a multiplier (in this case 3.5 times the standard deviation).
See also
mean
Determines how the line is calculated
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
bool
or a callable.str
.mean Formatoption instance in the plotter
str
.int
.Boolean that is True if an update of the formatoption requires a replot
Methods:
update
(value)Method that is call to update the formatoption on the axes
- children = ['mean']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- 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)
- property mean
mean Formatoption instance in the plotter
- name = 'Mean calculation'
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)
- requires_replot = True
Boolean that is True if an update of the formatoption requires a replot
- class psy_simple.plotters.ErrorPlot(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Visualize the error range
This formatoption visualizes the error range. For this, you must provide a two-dimensional data array as input. The first dimension might be either of length
2 to provide the deviation from minimum and maximum error range from the data
3 to provide the minimum and maximum error range explicitly
Possible types
None – No errors are visualized
‘fill’ – The area between min- and max-error is filled with the same color as the line and the alpha is determined by the
fillalpha
attribute
Examples
Assume you have the standard deviation stored in the
'std'
-variable and the data in the'data'
variable. Then you can visualize the standard deviation simply via:>>> psy.plot.lineplot(input_ds, name=[['data', 'std']])
On the other hand, assume you want to visualize the area between the 25th and 75th percentile (stored in the variables
'p25'
and'p75'
):>>> psy.plot.lineplot(input_ds, name=[['data', 'p25', 'p75']])
See also
erroralpha
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
color Formatoption instance in the plotter
bool
or a callable.str
.str
.plot Formatoption instance in the plotter
bool
.int
.transpose Formatoption instance in the plotter
Methods:
plot_fill
(index, min_range, max_range, c, ...)remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
- children = ['color', 'transpose', 'plot']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property color
color Formatoption instance in the plotter
- 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)
- name = 'Error plot type'
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
- property plot
plot Formatoption instance in the plotter
- priority = 20
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)
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.Extend(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.str
.plot Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- connections = ['plot']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- name = 'Ends of the colorbar'
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
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.FldmeanPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.LinePlotter
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
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.
Switch x- and y-axes
Set the x-axis limits
Set the y-axis limits
Color coding formatoptions:
Set the color coding
Set the alpha value for the error range
Data manipulation formatoptions:
Use an alternative variable as x-coordinate
Calculation of the error
Determine how the error is visualized
Plot formatoptions:
Visualize the error range
Choose the line style of the plot
Label formatoptions:
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:
Draw a legend
Set the labels of the arrays in the legend
Choose the width of the lines
Choose the marker for points
Choose the size of the markers for points
Make x- and y-axis symmetric
Change the ticksize of the ticklabels
Change the fontweight of the 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
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoptionAxis tick formatoptions:
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
- 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
- color
Set the color coding
This formatoptions sets the color of the lines, bars, etc.
Possible types
None – to use the axes color_cycle
iterable – (e.g. list) to specify the colors manually
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 – to automatically choose the colors according to the number of lines, etc. from the given colormap
- coord
Use an alternative variable as x-coordinate
This formatoption let’s you specify another variable in the base dataset of the data array in case you want to use this as the x-coordinate instead of the raw data
Possible types
None – Use the default
str – The name of the variable to use in the base dataset
xarray.DataArray – An alternative variable with the same shape as the displayed array
Examples
To see the difference, we create a simple test dataset:
>>> import xarray as xr >>> import numpy as np >>> import psyplot.project as psy >>> ds = xr.Dataset({ ... 'temp': xr.Variable(('time', ), np.arange(5)), ... 'std': xr.Variable(('time', ), np.arange(5, 10))}) >>> ds <xarray.Dataset> Dimensions: (time: 5) Coordinates: * time (time) int64 0 1 2 3 4 Data variables: temp (time) int64 0 1 2 3 4 std (time) int64 5 6 7 8 9
If we create a plot with it, we get the
'time'
dimension on the x-axis:>>> plotter = psy.plot.lineplot(ds, name=['temp']).plotters[0] >>> plotter.plot_data[0].dims ('time',)
If we however set the
'coord'
keyword, we get:>>> plotter = psy.plot.lineplot( ... ds, name=['temp'], coord='std').plotters[0] >>> plotter.plot_data[0].dims ('std',)
and
'std'
is plotted on the x-axis.
- err_calc
Calculation of the error
This formatoption is used to calculate the error range.
Possible types
None – Do not calculate any error range
float – A float between 0 and 50. This will represent the distance from the median (i.e. the 50th percentile). A value of 45 will hence correspond to the 5th and 95th percentile
list of 2 floats between 0 and 100 – Two floats where the first corresponds to the minimum and the second to the maximum percentile
str – A string with ‘std’ in it. Then we will use the standard deviation. Any number in this string, e.g. ‘3.5std’ will serve as a multiplier (in this case 3.5 times the standard deviation).
See also
mean
Determines how the line is calculated
- error
Visualize the error range
This formatoption visualizes the error range. For this, you must provide a two-dimensional data array as input. The first dimension might be either of length
2 to provide the deviation from minimum and maximum error range from the data
3 to provide the minimum and maximum error range explicitly
Possible types
None – No errors are visualized
‘fill’ – The area between min- and max-error is filled with the same color as the line and the alpha is determined by the
fillalpha
attribute
Examples
Assume you have the standard deviation stored in the
'std'
-variable and the data in the'data'
variable. Then you can visualize the standard deviation simply via:>>> psy.plot.lineplot(input_ds, name=[['data', 'std']])
On the other hand, assume you want to visualize the area between the 25th and 75th percentile (stored in the variables
'p25'
and'p75'
):>>> psy.plot.lineplot(input_ds, name=[['data', 'p25', 'p75']])
See also
- erroralpha
Set the alpha value for the error range
This formatoption can be used to set the alpha value (opacity) for the
error
formatoptionPossible types
float – A float between 0 and 1
See also
- 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()
functionNotes
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'
).
- 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
- legend
Draw a legend
This formatoption determines where and if to draw the legend. It uses the
labels
formatoption to determine the labels.Possible types
bool – Draw a legend or not
str or int – Specifies where to plot the legend (i.e. the location)
dict – Give the keywords for the
matplotlib.pyplot.legend()
function
See also
labels
- legendlabels
Set the labels of the arrays in the legend
This formatoption specifies the labels for each array in the legend. 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 – A single string that shall be used for all arrays.
list of str – Same as a single string but specified for each array
See also
- linewidth
Choose the width of the lines
Possible types
None – Use the default from matplotlibs rcParams
float – The width of the lines
- marker
Choose the marker for points
Possible types
None – Use the default from matplotlibs rcParams
str – A valid symbol for the matplotlib markers (see
matplotlib.markers
)
- markersize
Choose the size of the markers for points
Possible types
None – Use the default from matplotlibs rcParams
float – The size of the marker
- 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
- 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
- mean
Determine how the error is visualized
Possible types
‘mean’ – Calculate the weighted mean
‘median’ – Calculate the weighted median (i.e. the 50th percentile)
float between 0 and 100 – Calculate the given quantile
See also
err_calc
Determines how to calculate the error
- plot
Choose the line style of the plot
Possible types
None – Don’t make any plotting
'area'
– To make an area plot (filled between y=0 and y), seematplotlib.pyplot.fill_between()
'areax'
– To make a transposed area plot (filled between x=0 and x), seematplotlib.pyplot.fill_betweenx()
'stacked'
– Make a stacked plotstr or list of str – The line style string to use ([‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | ‘-’ | ‘–’ | ‘-.’ | ‘:’ | ‘None’ | ‘ ‘ | ‘’]).
- 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.Grid(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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'
).- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.str
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- class psy_simple.plotters.Hist2DXRange(*args, **kwargs)[source]
Bases:
psy_simple.plotters.LimitBase
Specify the range of the histogram for the x-dimension
This formatoption specifies the minimum and maximum of the histogram in the x-dimension
Possible types
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
Notes
This formatoption always acts on the coordinate, no matter what the value of the
transpose
formatoption isSee also
yrange
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
coord Formatoption instance in the plotter
bool
or a callable.list of str.
str
.str
.plot Formatoption instance in the plotter
int
.transpose Formatoption instance in the plotter
Methods:
set_limit
(*args)The method to set the minimum and maximum limit
- property array
The numpy array of the data
- property coord
coord Formatoption instance in the plotter
- 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 = ['coord']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Range of the histogram in x-direction'
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
- property plot
plot Formatoption instance in the plotter
- 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 transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.Hist2DYRange(*args, **kwargs)[source]
Bases:
psy_simple.plotters.Hist2DXRange
Specify the range of the histogram for the x-dimension
This formatoption specifies the minimum and maximum of the histogram in the x-dimension
Possible types
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
Notes
This formatoption always acts on the DataArray, no matter what the value of the
transpose
formatoption isSee also
xrange
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
coord Formatoption instance in the plotter
bool
or a callable.str
.plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
- property array
The numpy array of the data
- property coord
coord Formatoption instance in the plotter
- 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)
- name = 'Range of the histogram in y-direction'
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
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.HistBins(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Specify the bins of the 2D-Histogramm
This formatoption can be used to specify, how many bins to use. In other words, it determines the grid size of the resulting histogram or kde plot. If however you also set the
precision
formatoption keyword then the minimum of precision and the bins specified here will be used.Possible types
int – If 0, only use the bins specified by the
precision
keyword (raises an error if theprecision
is also set to 0), otherwise the number of bins to usetuple (x, y) of int – The bins for x and y explicitly
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.list of str.
str
.str
.precision Formatoption instance in the plotter
int
.Methods:
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 = ['precision']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Number of bins of the histogram'
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
- property precision
precision Formatoption instance in the plotter
- class psy_simple.plotters.InterpolateBounds(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- class psy_simple.plotters.LabelOptions(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.DictFormatoption
Base formatoption class for label sizes
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.- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
xlabel Formatoption instance in the plotter
ylabel Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
update_axis
(value)- children = ['xlabel', 'ylabel']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property xlabel
xlabel Formatoption instance in the plotter
- property ylabel
ylabel Formatoption instance in the plotter
- class psy_simple.plotters.LabelProps(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.LabelOptions
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.labelsize Formatoption instance in the plotter
labelweight Formatoption instance in the plotter
str
.xlabel Formatoption instance in the plotter
ylabel Formatoption instance in the plotter
Methods:
update_axis
(fontprops)- children = ['xlabel', 'ylabel', 'labelsize', 'labelweight']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property labelsize
labelsize Formatoption instance in the plotter
- property labelweight
labelweight Formatoption instance in the plotter
- name = 'font properties of x- and y-axis label'
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
- property xlabel
xlabel Formatoption instance in the plotter
- property ylabel
ylabel Formatoption instance in the plotter
- class psy_simple.plotters.LabelSize(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.LabelOptions
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
xlabel
,ylabel
,labelweight
,labelprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.labelprops Formatoption instance in the plotter
str
.list of str.
xlabel Formatoption instance in the plotter
ylabel Formatoption instance in the plotter
Methods:
update_axis
(value)- property labelprops
labelprops Formatoption instance in the plotter
- name = 'font size of x- and y-axis label'
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
- parents = ['labelprops']
list of str. List of formatoptions that, if included in the update, prevent the update of this formatoption.
- property xlabel
xlabel Formatoption instance in the plotter
- property ylabel
ylabel Formatoption instance in the plotter
- class psy_simple.plotters.LabelWeight(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.LabelOptions
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
xlabel
,ylabel
,labelsize
,labelprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.labelprops Formatoption instance in the plotter
str
.list of str.
xlabel Formatoption instance in the plotter
ylabel Formatoption instance in the plotter
Methods:
update_axis
(value)- property labelprops
labelprops Formatoption instance in the plotter
- name = 'font weight of x- and y-axis label'
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
- parents = ['labelprops']
list of str. List of formatoptions that, if included in the update, prevent the update of this formatoption.
- property xlabel
xlabel Formatoption instance in the plotter
- property ylabel
ylabel Formatoption instance in the plotter
- class psy_simple.plotters.Legend(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.DictFormatoption
Draw a legend
This formatoption determines where and if to draw the legend. It uses the
labels
formatoption to determine the labels.Possible types
bool – Draw a legend or not
str or int – Specifies where to plot the legend (i.e. the location)
dict – Give the keywords for the
matplotlib.pyplot.legend()
function
See also
labels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
color Formatoption instance in the plotter
list of str.
legendlabels Formatoption instance in the plotter
marker Formatoption instance in the plotter
str
.plot Formatoption instance in the plotter
Methods:
remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
- property color
color Formatoption instance in the plotter
- dependencies = ['legendlabels', 'plot', 'color', 'marker']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property legendlabels
legendlabels Formatoption instance in the plotter
- property marker
marker Formatoption instance in the plotter
- name = 'Properties of the legend'
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
- property plot
plot Formatoption instance in the plotter
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- class psy_simple.plotters.LegendLabels(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
,psy_simple.base.TextBase
Set the labels of the arrays in the legend
This formatoption specifies the labels for each array in the legend. 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 – A single string that shall be used for all arrays.
list of str – Same as a single string but specified for each array
See also
legend
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.str
.Methods:
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)
- class psy_simple.plotters.LimitBase(*args, **kwargs)[source]
Bases:
psy_simple.plotters.DataTicksCalculator
Base class for x- and y-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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
list of str.
str
.plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
The value that is passed to shared formatoptions (by default, the
value
attribute)Methods:
set_limit
(min_val, max_val)The method to set the minimum and maximum limit
update
(value)Method that is call to update the formatoption on the axes
- children = ['transpose']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- connections = ['plot']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
The value that is passed to shared formatoptions (by default, the
value
attribute)
- class psy_simple.plotters.LineColors(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Set the color coding
This formatoptions sets the color of the lines, bars, etc.
Possible types
None – to use the axes color_cycle
iterable – (e.g. list) to specify the colors manually
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 – to automatically choose the colors according to the number of lines, etc. from the given colormap
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.str
.int
.The value that can be used when pickling the information of the project
The value that is passed to shared formatoptions (by default, the
value
attribute)Methods:
update
(value)Method that is call to update the formatoption on the axes
- property extended_colors
- name = 'Color cycle'
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 = 20
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)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property value2pickle
The value that can be used when pickling the information of the project
The value that is passed to shared formatoptions (by default, the
value
attribute)
- class psy_simple.plotters.LinePlot(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Choose the line style of the plot
Possible types
None – Don’t make any plotting
'area'
– To make an area plot (filled between y=0 and y), seematplotlib.pyplot.fill_between()
'areax'
– To make a transposed area plot (filled between x=0 and x), seematplotlib.pyplot.fill_betweenx()
'stacked'
– Make a stacked plotstr or list of str – The line style string to use ([‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | ‘-’ | ‘–’ | ‘-.’ | ‘:’ | ‘None’ | ‘ ‘ | ‘’]).
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
color Formatoption instance in the plotter
bool
or a callable.str
.marker Formatoption instance in the plotter
str
.bool
.The data that is shown to the user
int
.transpose Formatoption instance in the plotter
Methods:
plot_arr
(arr, c, ls, m)remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
- children = ['color', 'transpose', 'marker']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property color
color Formatoption instance in the plotter
- 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)
- property marker
marker Formatoption instance in the plotter
- name = 'Line plot type'
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
- property plotted_data
The data that is shown to the user
- priority = 20.1
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)
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.LinePlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.SimplePlotterBase
Plotter for simple one-dimensional line plots
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Attributes:
The number variables that one data array visualized by this plotter might have.
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Switch x- and y-axes
Set the x-axis limits
Set the y-axis limits
Color coding formatoptions:
Set the color coding
Set the alpha value for the error range
Data manipulation formatoptions:
Use an alternative variable as x-coordinate
Plot formatoptions:
Visualize the error range
Choose the line style of the plot
Label formatoptions:
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:
Draw a legend
Set the labels of the arrays in the legend
Choose the width of the lines
Choose the marker for points
Choose the size of the markers for points
Make x- and y-axis symmetric
Change the ticksize of the ticklabels
Change the fontweight of the 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
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoptionAxis tick formatoptions:
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
- allowed_vars = 3
The number variables that one data array visualized by this plotter might have. We allow up to 3 variableswhere the second and third variable might be the errors (see the
error
formatoption)
- 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
- color
Set the color coding
This formatoptions sets the color of the lines, bars, etc.
Possible types
None – to use the axes color_cycle
iterable – (e.g. list) to specify the colors manually
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 – to automatically choose the colors according to the number of lines, etc. from the given colormap
- coord
Use an alternative variable as x-coordinate
This formatoption let’s you specify another variable in the base dataset of the data array in case you want to use this as the x-coordinate instead of the raw data
Possible types
None – Use the default
str – The name of the variable to use in the base dataset
xarray.DataArray – An alternative variable with the same shape as the displayed array
Examples
To see the difference, we create a simple test dataset:
>>> import xarray as xr >>> import numpy as np >>> import psyplot.project as psy >>> ds = xr.Dataset({ ... 'temp': xr.Variable(('time', ), np.arange(5)), ... 'std': xr.Variable(('time', ), np.arange(5, 10))}) >>> ds <xarray.Dataset> Dimensions: (time: 5) Coordinates: * time (time) int64 0 1 2 3 4 Data variables: temp (time) int64 0 1 2 3 4 std (time) int64 5 6 7 8 9
If we create a plot with it, we get the
'time'
dimension on the x-axis:>>> plotter = psy.plot.lineplot(ds, name=['temp']).plotters[0] >>> plotter.plot_data[0].dims ('time',)
If we however set the
'coord'
keyword, we get:>>> plotter = psy.plot.lineplot( ... ds, name=['temp'], coord='std').plotters[0] >>> plotter.plot_data[0].dims ('std',)
and
'std'
is plotted on the x-axis.
- error
Visualize the error range
This formatoption visualizes the error range. For this, you must provide a two-dimensional data array as input. The first dimension might be either of length
2 to provide the deviation from minimum and maximum error range from the data
3 to provide the minimum and maximum error range explicitly
Possible types
None – No errors are visualized
‘fill’ – The area between min- and max-error is filled with the same color as the line and the alpha is determined by the
fillalpha
attribute
Examples
Assume you have the standard deviation stored in the
'std'
-variable and the data in the'data'
variable. Then you can visualize the standard deviation simply via:>>> psy.plot.lineplot(input_ds, name=[['data', 'std']])
On the other hand, assume you want to visualize the area between the 25th and 75th percentile (stored in the variables
'p25'
and'p75'
):>>> psy.plot.lineplot(input_ds, name=[['data', 'p25', 'p75']])
See also
- erroralpha
Set the alpha value for the error range
This formatoption can be used to set the alpha value (opacity) for the
error
formatoptionPossible types
float – A float between 0 and 1
See also
- 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()
functionNotes
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'
).
- 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
- legend
Draw a legend
This formatoption determines where and if to draw the legend. It uses the
labels
formatoption to determine the labels.Possible types
bool – Draw a legend or not
str or int – Specifies where to plot the legend (i.e. the location)
dict – Give the keywords for the
matplotlib.pyplot.legend()
function
See also
labels
- legendlabels
Set the labels of the arrays in the legend
This formatoption specifies the labels for each array in the legend. 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 – A single string that shall be used for all arrays.
list of str – Same as a single string but specified for each array
See also
- linewidth
Choose the width of the lines
Possible types
None – Use the default from matplotlibs rcParams
float – The width of the lines
- marker
Choose the marker for points
Possible types
None – Use the default from matplotlibs rcParams
str – A valid symbol for the matplotlib markers (see
matplotlib.markers
)
- markersize
Choose the size of the markers for points
Possible types
None – Use the default from matplotlibs rcParams
float – The size of the marker
- 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
- 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
- plot
Choose the line style of the plot
Possible types
None – Don’t make any plotting
'area'
– To make an area plot (filled between y=0 and y), seematplotlib.pyplot.fill_between()
'areax'
– To make a transposed area plot (filled between x=0 and x), seematplotlib.pyplot.fill_betweenx()
'stacked'
– Make a stacked plotstr or list of str – The line style string to use ([‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | ‘-’ | ‘–’ | ‘-.’ | ‘:’ | ‘None’ | ‘ ‘ | ‘’]).
- 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.LineWidth(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Choose the width of the lines
Possible types
None – Use the default from matplotlibs rcParams
float – The width of the lines
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
plot Formatoption instance in the plotter
int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- connections = ['plot']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.Marker(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Choose the marker for points
Possible types
None – Use the default from matplotlibs rcParams
str – A valid symbol for the matplotlib markers (see
matplotlib.markers
)
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- class psy_simple.plotters.MarkerSize(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Choose the size of the markers for points
Possible types
None – Use the default from matplotlibs rcParams
float – The size of the marker
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
plot Formatoption instance in the plotter
int
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- connections = ['plot']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.MaskDataGrid(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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
datagrid
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
update
(value)dummy, since this fmt is considered in the :class:`DataGrid ` fmt
- class psy_simple.plotters.MeanCalculator(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Determine how the error is visualized
Possible types
‘mean’ – Calculate the weighted mean
‘median’ – Calculate the weighted median (i.e. the 50th percentile)
float between 0 and 100 – Calculate the given quantile
See also
err_calc
Determines how to calculate the error
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.str
.str
.int
.Boolean that is True if an update of the formatoption requires a replot
Methods:
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)
- name = 'Mean calculation'
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)
- requires_replot = True
Boolean that is True if an update of the formatoption requires a replot
- class psy_simple.plotters.MissColor(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Set the color for missing values
Possible types
None – Use the default from the colormap
string, tuple. – Defines the color of the grid.
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
list of str.
str
.str
.plot Formatoption instance in the plotter
int
.transform Formatoption instance in the plotter
bool
.Methods:
remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
- connections = ['transform']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- dependencies = ['plot']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Color of missing values'
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
- property plot
plot Formatoption instance in the plotter
- priority = 10
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)
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- property transform
transform Formatoption instance in the plotter
- class psy_simple.plotters.NormedHist2D(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Specify the normalization of the histogram
This formatoption can be used to normalize the histogram. It has no effect if the
density
formatoption is set to'kde'
Possible types
None – Do not make any normalization
str – One of
- counts
To make the normalization based on the total number counts
- area
To make the normalization basen on the total number of counts and area (the default behaviour of
numpy.histogram2d()
)- x, col, column or columns
To normalize every column
- y, row or rows
To normalize every row
See also
density
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.str
.str
.int
.Methods:
hist2d
(da, **kwargs)Make the two dimensional histogram
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)
- hist2d(da, **kwargs)[source]
Make the two dimensional histogram
- Parameters
da (xarray.DataArray) – The data source
- name = 'Normalize the histogram'
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
- class psy_simple.plotters.Plot2D(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Choose how to visualize a 2-dimensional scalar data field
Possible types
None – Don’t make any plotting
‘mesh’ – Use the
matplotlib.pyplot.pcolormesh()
function to make the plot or thematplotlib.pyplot.tripcolor()
for an unstructered grid‘poly’ – Draw each polygon indivually. This method is used by default for unstructured grids. If there are no grid cell boundaries in the dataset, we will interpolate them
‘contourf’ – Make a filled contour plot using the
matplotlib.pyplot.contourf()
function. The levels for the contour plot are controlled by thelevels
formatoption‘contour’ – Same a
'contourf'
, but does not make a filled contour plot, only lines.
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
add2format_coord
(x, y)Additional information for the
format_coord()
get_xyz_1d
(xcoord, x, ycoord, y, data)Get closest x, y and z for the given x and y in data for 1d coords
get_xyz_2d
(xcoord, x, ycoord, y, data)Get closest x, y and z for the given x and y in data for 2d coords
get_xyz_tri
(xcoord, x, ycoord, y, data)Get closest x, y and z for the given x and y in data for 1d coords
remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
Attributes:
The (masked) data array that is plotted
bounds Formatoption instance in the plotter
The unstructured x-boundaries with shape (N, m) where m > 2
The unstructured y-boundaries with shape (N, m) where m > 2
list of str.
cmap Formatoption instance in the plotter
bool
or a callable.list of str.
The function that can replace the axes.format_coord method
str
.interp_bounds Formatoption instance in the plotter
levels Formatoption instance in the plotter
Returns the mappable that can be used for colorbars
str
.The data array that is plotted
bool
.int
.Boundaries of the x-coordinate
The x coordinate
xarray.Variable
Boundaries of the y-coordinate
The y coordinate
xarray.Variable
- add2format_coord(x, y)[source]
Additional information for the
format_coord()
- property array
The (masked) data array that is plotted
- property bounds
bounds Formatoption instance in the plotter
- property cell_nodes_x
The unstructured x-boundaries with shape (N, m) where m > 2
- property cell_nodes_y
The unstructured y-boundaries with shape (N, m) where m > 2
- children = ['cmap', 'bounds']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property cmap
cmap Formatoption instance in the plotter
- 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 = ['levels', 'interp_bounds']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property format_coord
The function that can replace the axes.format_coord method
- get_xyz_1d(xcoord, x, ycoord, y, data)[source]
Get closest x, y and z for the given x and y in data for 1d coords
- get_xyz_2d(xcoord, x, ycoord, y, data)[source]
Get closest x, y and z for the given x and y in data for 2d coords
- get_xyz_tri(xcoord, x, ycoord, y, data)[source]
Get closest x, y and z for the given x and y in data for 1d coords
- property interp_bounds
interp_bounds Formatoption instance in the plotter
- property levels
levels Formatoption instance in the plotter
- property mappable
Returns the mappable that can be used for colorbars
- name = '2D plot type'
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
- property notnull_array
The data array that is plotted
- priority = 20
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)
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property xbounds
Boundaries of the x-coordinate
- property xcoord
The x coordinate
xarray.Variable
- property ybounds
Boundaries of the y-coordinate
- property ycoord
The y coordinate
xarray.Variable
- class psy_simple.plotters.PointDensity(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Specify the method to calculate the density
Possible types
str – One of the following strings are possible
- hist
Make a 2D-histogram. The normalization is controlled by the
normed
formatoption- kde
Fit a bivariate kernel density estimate to the data. Note that this choice requires pythons [statsmodels] module to be installed
References
- statsmodels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bins Formatoption instance in the plotter
coord Formatoption instance in the plotter
bool
or a callable.list of str.
str
.str
.normed Formatoption instance in the plotter
precision Formatoption instance in the plotter
int
.xrange Formatoption instance in the plotter
yrange Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- property bins
bins Formatoption instance in the plotter
- property coord
coord Formatoption instance in the plotter
- 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 = ['normed', 'bins', 'xrange', 'yrange', 'precision', 'coord']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Calculation of the point density'
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
- property normed
normed Formatoption instance in the plotter
- property precision
precision Formatoption instance in the plotter
- 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)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property xrange
xrange Formatoption instance in the plotter
- property yrange
yrange Formatoption instance in the plotter
- class psy_simple.plotters.ScalarCombinedBase(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psyplot.plotter.Plotter
Base plotter for combined 2-dimensional scalar field with any other plotter
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Color coding formatoptions:
Specify the boundaries of the colorbar
Specify the position of the colorbars
Axis tick formatoptions:
Specify the tick locations of the colorbar
Masking formatoptions:
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
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoption- 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 necessarydict – 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')
- 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 necessarydict – 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
cticklabels
- 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
- 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
- class psy_simple.plotters.Simple2DBase(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.Base2D
Base class for
Simple2DPlotter
andpsyplot.plotter.maps.FieldPlotter
that defines the data management- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Attributes:
The number of allowed dimensions in the for the visualization.
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
Set the color for missing values
Methods:
check_data
(name, dims, is_unstructured)A validation method for the data shape
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
Axis tick formatoptions:
Specify the colorbar ticklabels
Specify the tick locations of the colorbar
Miscallaneous formatoptions:
Show the grid of the data
Mask the datagrid where the array is NaN
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoption- allowed_dims = 2
The number of allowed dimensions in the for the visualization. If the array is unstructured, one dimension will be subtracted
- 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 necessarydict – 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
- classmethod check_data(name, dims, is_unstructured)[source]
A validation method for the data shape
- Parameters
- Returns
list of bool or None – True, if everything is okay, False in case of a serious error, None if it is intermediate. Each object in this list corresponds to one in the given name
list of str – The message giving more information on the reason. Each object in this list corresponds to one in the given name
- 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
- 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 integersarray – 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()
functionSee 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 necessarydict – 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
- 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
- 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.
- 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
- class psy_simple.plotters.Simple2DPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.Simple2DBase
,psy_simple.plotters.SimplePlotterBase
Plotter for visualizing 2-dimensional data.
See also
psyplot.plotter.maps.FieldPlotter
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Switch x- and y-axes
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
Attributes:
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
Miscallaneous formatoptions:
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
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- 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 necessarydict – 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
- color = None
- 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 integersarray – 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()
functionSee 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 necessarydict – 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()
functionNotes
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
- legend = None
- legendlabels = None
- 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 11numeric 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 necessarydict – 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.SimplePlot2D(*args, **kwargs)[source]
Bases:
psy_simple.plotters.Plot2D
Specify the plotting method
Possible types
None – Don’t make any plotting
‘mesh’ – Use the
matplotlib.pyplot.pcolormesh()
function to make the plot
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The (masked) data array that is plotted
bounds Formatoption instance in the plotter
The unstructured x-boundaries with shape (N, m) where m > 2
The unstructured y-boundaries with shape (N, m) where m > 2
cmap Formatoption instance in the plotter
bool
or a callable.list of str.
interp_bounds Formatoption instance in the plotter
levels Formatoption instance in the plotter
transpose Formatoption instance in the plotter
Boundaries of the x-coordinate
The x coordinate
xarray.Variable
Boundaries of the y-coordinate
The y coordinate
xarray.Variable
- property array
The (masked) data array that is plotted
- property bounds
bounds Formatoption instance in the plotter
- property cell_nodes_x
The unstructured x-boundaries with shape (N, m) where m > 2
- property cell_nodes_y
The unstructured y-boundaries with shape (N, m) where m > 2
- property cmap
cmap Formatoption instance in the plotter
- 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 = ['levels', 'interp_bounds', 'transpose']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property interp_bounds
interp_bounds Formatoption instance in the plotter
- property levels
levels Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xbounds
Boundaries of the x-coordinate
- property xcoord
The x coordinate
xarray.Variable
- property ybounds
Boundaries of the y-coordinate
- property ycoord
The y coordinate
xarray.Variable
- class psy_simple.plotters.SimplePlotterBase(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.base.BasePlotter
,psy_simple.plotters.XYTickPlotter
Base class for all simple plotters
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Attributes:
The number of allowed dimensions in the for the visualization.
The number variables that one data array visualized by this plotter might have.
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Switch x- and y-axes
Set the x-axis limits
Set the y-axis limits
Methods:
check_data
(name, dims[, is_unstructured])A validation method for the data shape
Color coding formatoptions:
Set the color coding
Label formatoptions:
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:
Draw a legend
Set the labels of the arrays in the legend
Make x- and y-axis symmetric
Change the ticksize of the ticklabels
Change the fontweight of the 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
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoptionAxis tick formatoptions:
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
- allowed_dims = 1
The number of allowed dimensions in the for the visualization. If the array is unstructured, one dimension will be subtracted
- allowed_vars = 1
The number variables that one data array visualized by this plotter might have.
- 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
- classmethod check_data(name, dims, is_unstructured=None)[source]
A validation method for the data shape
- Parameters
name (str or list of str) – The variable names (at maximum
allowed_vars
variables per array)dims (list with length 1 or list of lists with length 1) – The dimension of the arrays. Only 1D-Arrays are allowed
is_unstructured (bool or list of bool, optional) – True if the corresponding array is unstructured. This keyword is ignored
- Returns
list of bool or None – True, if everything is okay, False in case of a serious error, None if it is intermediate. Each object in this list corresponds to one in the given name
list of str – The message giving more information on the reason. Each object in this list corresponds to one in the given name
- color
Set the color coding
This formatoptions sets the color of the lines, bars, etc.
Possible types
None – to use the axes color_cycle
iterable – (e.g. list) to specify the colors manually
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 – to automatically choose the colors according to the number of lines, etc. from the given colormap
- 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()
functionNotes
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'
).
- 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
- legend
Draw a legend
This formatoption determines where and if to draw the legend. It uses the
labels
formatoption to determine the labels.Possible types
bool – Draw a legend or not
str or int – Specifies where to plot the legend (i.e. the location)
dict – Give the keywords for the
matplotlib.pyplot.legend()
function
See also
labels
- legendlabels
Set the labels of the arrays in the legend
This formatoption specifies the labels for each array in the legend. 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 – A single string that shall be used for all arrays.
list of str – Same as a single string but specified for each array
See also
- 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
- 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
- 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.SimpleVectorPlot(*args, **kwargs)[source]
Bases:
psy_simple.plotters.VectorPlot
Choose the vector plot type
Possible types
str – Plot types can be either
- quiver
to make a quiver plot
- stream
to make a stream plot
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
arrowsize Formatoption instance in the plotter
arrowstyle Formatoption instance in the plotter
bounds Formatoption instance in the plotter
cmap Formatoption instance in the plotter
color Formatoption instance in the plotter
bool
or a callable.density Formatoption instance in the plotter
linewidth Formatoption instance in the plotter
transform Formatoption instance in the plotter
transpose Formatoption instance in the plotter
Methods:
set_value
(value, *args, **kwargs)Set (and validate) the value in the plotter.
- property arrowsize
arrowsize Formatoption instance in the plotter
- property arrowstyle
arrowstyle Formatoption instance in the plotter
- property bounds
bounds Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- property color
color Formatoption instance in the plotter
- 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)
- property density
density Formatoption instance in the plotter
- property linewidth
linewidth Formatoption instance in the plotter
- set_value(value, *args, **kwargs)[source]
Set (and validate) the value in the plotter. This method is called by the plotter when it attempts to change the value of the formatoption.
- property transform
transform Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.SimpleVectorPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.BaseVectorPlotter
,psy_simple.plotters.SimplePlotterBase
Plotter for visualizing 2-dimensional vector data
See also
psyplot.plotter.maps.VectorPlotter
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Vector plot formatoptions:
Change the size of the arrows
Change the style of the arrows
Change the density of the arrows
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Switch x- and y-axes
Set the x-axis limits
Set the y-axis limits
Color coding formatoptions:
Specify the boundaries of the vector colorbar
Specify the position of the vector plot colorbars
Specify the spacing of the bounds in the colorbar
Specify the color map
Set the color for the arrows
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
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
Axis tick formatoptions:
Specify the colorbar ticklabels
Specify the tick locations of the vector 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
Miscallaneous formatoptions:
Change the linewidth of the arrows
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
Attributes:
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:
Choose the vector plot type
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoption- arrowsize
Change the size of the arrows
Possible types
None – make no scaling
float – Factor scaling the size of the arrows
See also
- arrowstyle
Change the style of the arrows
Possible types
str – Any arrow style string (see
FancyArrowPatch
)Notes
This formatoption only has an effect for stream plots
- 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 vector 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 necessarydict – 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 vector plot 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
- 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
- color
Set the color for the arrows
This formatoption can be used to set a single color for the vectors or define the color coding
Possible types
float – Determines the greyness
color – Defines the same color for all arrows. The string can be either a html hex string (e.g. ‘#eeefff’), a single letter (e.g. ‘b’: blue, ‘g’: green, ‘r’: red, ‘c’: cyan, ‘m’: magenta, ‘y’: yellow, ‘k’: black, ‘w’: white) or any other color
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
2D-array – The values determine the color for each plotted arrow. Note that the shape has to match the one of u and v.
See also
- 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 integersarray – 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()
functionSee also
cticksize
,ctickweight
,cticklabels
,cticks
,vcticksize
,vctickweight
,vcticklabels
,vcticks
- cticks
Specify the tick locations of the vector 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 necessarydict – 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
cticklabels
,vcticklabels
- 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
- density
Change the density of the arrows
Possible types
float – Scales the density of the arrows in x- and y-direction (1.0 means no scaling)
tuple (x, y) – Defines the scaling in x- and y-direction manually
Notes
quiver plots do not support density scaling
- 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()
functionNotes
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'
).
- 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
- legend = None
- legendlabels = None
- linewidth
Change the linewidth of the arrows
Possible types
float – give the linewidth explicitly
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
tuple (string, float) – string may be one of the above strings, float may be a scaling factor
2D-array – The values determine the linewidth for each plotted arrow. Note that the shape has to match the one of u and v.
See also
- 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
- plot
Choose the vector plot type
Possible types
str – Plot types can be either
- quiver
to make a quiver plot
- stream
to make a stream 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.SymmetricLimits(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.xlim Formatoption instance in the plotter
ylim Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- dependencies = ['xlim', 'ylim']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Symmetric x- and y-axis limits'
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)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property xlim
xlim Formatoption instance in the plotter
- property ylim
ylim Formatoption instance in the plotter
- class psy_simple.plotters.TickLabels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.TickLabelsBase
,psy_simple.plotters.TicksManager
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
set_default_formatters
([which])Sets the default formatters that is used for updating to None
set_formatter
(formatter[, which])Sets a given formatter
update
(value)Method that is call to update the formatoption on the axes
Attributes:
transpose Formatoption instance in the plotter
- set_default_formatters(which=None)[source]
Sets the default formatters that is used for updating to None
- Parameters
which ({None, 'minor', 'major'}) – Specify which locator shall be set
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.TickLabelsBase(*args, **kwargs)[source]
Bases:
psy_simple.plotters.TicksManagerBase
Abstract base class for 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 integersarray – An array of strings to use for the ticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The axis on the axes to modify the ticks of
list of str.
str
.transpose Formatoption instance in the plotter
Methods:
initialize_plot
(value)Method that is called when the plot is made the first time
Sets the default formatters that is used for updating to None
set_formatter
(formatter)Sets a given formatter
set_ticklabels
(labels)Sets the given tick labels
update_axis
(value)- abstract property axis
The axis on the axes to modify the ticks of
- dependencies = ['transpose']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- initialize_plot(value)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- abstract set_default_formatters()[source]
Sets the default formatters that is used for updating to None
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.TickPropsBase(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.TicksManagerBase
Abstract base class for tick parameters
Possible types
dict – Items may be anything of the
matplotlib.pyplot.tick_params()
function- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The name of the axis (either 'x' or 'y')
Methods:
update_axis
(value)- abstract property axisname
The name of the axis (either ‘x’ or ‘y’)
- class psy_simple.plotters.TickSize(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.TickSizeBase
,psy_simple.plotters.TicksOptions
,psyplot.plotter.DictFormatoption
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
,xtickprops
,ytickprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.xtickprops Formatoption instance in the plotter
ytickprops Formatoption instance in the plotter
- dependencies = ['xtickprops', 'ytickprops']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Font size of the ticklabels'
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
- property xtickprops
xtickprops Formatoption instance in the plotter
- property ytickprops
ytickprops Formatoption instance in the plotter
- class psy_simple.plotters.TickSizeBase(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.TicksOptions
Abstract base class for modifying tick sizes
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
update_axis
(value)
- class psy_simple.plotters.TickWeight(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.TickWeightBase
,psy_simple.plotters.TicksOptions
,psyplot.plotter.DictFormatoption
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
ticksize
,xtickprops
,ytickprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.xtickprops Formatoption instance in the plotter
ytickprops Formatoption instance in the plotter
- dependencies = ['xtickprops', 'ytickprops']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Font weight of the ticklabels'
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
- property xtickprops
xtickprops Formatoption instance in the plotter
- property ytickprops
ytickprops Formatoption instance in the plotter
- class psy_simple.plotters.TickWeightBase(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.TicksOptions
Abstract base class for modifying font weight of ticks
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
update_axis
(value)
- class psy_simple.plotters.TicksBase(*args, **kwargs)[source]
Bases:
psy_simple.plotters.TicksManagerBase
,psy_simple.plotters.DataTicksCalculator
Abstract base class for calculating ticks
Possible types
None – use the default ticks
int – for an integer i, only every i-th tick of the default ticks are used
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
Methods:
initialize_plot
(value)Method that is called when the plot is made the first time
set_default_locators
([which])Sets the default locator that is used for updating to None or int
set_locator
(locator)Sets the locator corresponding of the axis
set_ticks
(value)update_axis
(value)- abstract property axis
- dependencies = ['transpose', 'plot']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- initialize_plot(value)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- property plot
plot Formatoption instance in the plotter
- set_default_locators(which=None)[source]
Sets the default locator that is used for updating to None or int
- Parameters
which ({None, 'minor', 'major'}) – Specify which locator shall be set
- set_locator(locator)[source]
Sets the locator corresponding of the axis
- Parameters
locator (matplotlib.ticker.Locator) – The locator to set
which ({None, 'minor', 'major'}) – Specify which locator shall be set. If None, it will be taken from the
which
attribute
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.TicksManager(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.TicksManagerBase
,psyplot.plotter.DictFormatoption
Abstract base class for ticks formatoptions controlling major and minor ticks
This formatoption simply serves as a base that allows the simultaneous managment of major and minor 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.- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.Methods:
update
(value)Method that is call to update the formatoption on the axes
- class psy_simple.plotters.TicksManagerBase(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Abstract base class for formatoptions handling ticks
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
update_axis
(val)
- class psy_simple.plotters.TicksOptions(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.TicksManagerBase
Base class for ticklabels options that apply for x- and y-axis
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
update
(value)Method that is call to update the formatoption on the axes
- class psy_simple.plotters.Transpose(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
get_x
(arr)get_y
(arr)initialize_plot
(value)Method that is called when the plot is made the first time
update
(value)Method that is call to update the formatoption on the axes
Attributes:
str
.str
.int
.- initialize_plot(value)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- name = 'Switch x- and y-axes'
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
- class psy_simple.plotters.VCLabel(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.CLabel
Show the colorbar label of the vector plot
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
vclabelsize
,vclabelweight
,vclabelprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
cbar Formatoption instance in the plotter
plot Formatoption instance in the plotter
- property cbar
cbar Formatoption instance in the plotter
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.VectorBounds(*args, **kwargs)[source]
Bases:
psy_simple.plotters.Bounds
Specify the boundaries of the vector 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 necessarydict – 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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
cbar Formatoption instance in the plotter
cmap Formatoption instance in the plotter
color Formatoption instance in the plotter
list of str.
Methods:
update
(*args, **kwargs)Method that is call to update the formatoption on the axes
- property array
The numpy array of the data
- property cbar
cbar Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- property color
color Formatoption instance in the plotter
- parents = ['color']
list of str. List of formatoptions that, if included in the update, prevent the update of this formatoption.
- class psy_simple.plotters.VectorCTicks(*args, **kwargs)[source]
Bases:
psy_simple.plotters.CTicks
Specify the tick locations of the vector 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 necessarydict – 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
cticklabels
,vcticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
bounds Formatoption instance in the plotter
cbar Formatoption instance in the plotter
cmap Formatoption instance in the plotter
color Formatoption instance in the plotter
list of str.
plot Formatoption instance in the plotter
- property array
The numpy array of the data
- property bounds
bounds Formatoption instance in the plotter
- property cbar
cbar Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- property color
color Formatoption instance in the plotter
- dependencies = ['cbar', 'bounds', 'color']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.VectorCalculator(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Abstract formatoption that provides calculation functions for speed, etc.
Possible types
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.list of str.
plot Formatoption instance in the plotter
int
.transpose Formatoption instance in the plotter
- 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 = ['plot', 'transpose']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property plot
plot Formatoption instance in the plotter
- priority = 20
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 transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.VectorCbar(*args, **kwargs)[source]
Bases:
psy_simple.plotters.Cbar
Specify the position of the vector plot 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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.other_cbars (list of str) – List of other colorbar formatoption keys (necessary for a sufficient resizing of the axes)
Attributes:
bounds Formatoption instance in the plotter
cbarspacing Formatoption instance in the plotter
cmap Formatoption instance in the plotter
color Formatoption instance in the plotter
list of str.
extend Formatoption instance in the plotter
levels Formatoption instance in the plotter
plot Formatoption instance in the plotter
int
.Methods:
update
(*args, **kwargs)Updates the colorbar
- property bounds
bounds Formatoption instance in the plotter
- property cbarspacing
cbarspacing Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- property color
color Formatoption instance in the plotter
- dependencies = ['plot', 'cmap', 'bounds', 'extend', 'cbarspacing', 'levels', 'color']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- property extend
extend Formatoption instance in the plotter
- property levels
levels Formatoption instance in the plotter
- property plot
plot Formatoption instance in the plotter
- class psy_simple.plotters.VectorColor(*args, **kwargs)[source]
Bases:
psy_simple.plotters.VectorCalculator
Set the color for the arrows
This formatoption can be used to set a single color for the vectors or define the color coding
Possible types
float – Determines the greyness
color – Defines the same color for all arrows. The string can be either a html hex string (e.g. ‘#eeefff’), a single letter (e.g. ‘b’: blue, ‘g’: green, ‘r’: red, ‘c’: cyan, ‘m’: magenta, ‘y’: yellow, ‘k’: black, ‘w’: white) or any other color
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
2D-array – The values determine the color for each plotted arrow. Note that the shape has to match the one of u and v.
See also
arrowsize
,arrowstyle
,density
,linewidth
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bounds Formatoption instance in the plotter
cmap Formatoption instance in the plotter
list of str.
str
.str
.plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- property bounds
bounds Formatoption instance in the plotter
- property cmap
cmap Formatoption instance in the plotter
- dependencies = ['plot', 'transpose', 'cmap', 'bounds']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Color of the arrows'
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
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.VectorDataGrid(*args, **kwargs)[source]
Bases:
psy_simple.plotters.DataGrid
- Parameters
%(Formatoption.parameters)s –
Attributes:
The data that is plotted
mask_datagrid Formatoption instance in the plotter
plot Formatoption instance in the plotter
transform Formatoption instance in the plotter
- property data
The data that is plotted
- property mask_datagrid
mask_datagrid Formatoption instance in the plotter
- property plot
plot Formatoption instance in the plotter
- property transform
transform Formatoption instance in the plotter
- class psy_simple.plotters.VectorLineWidth(*args, **kwargs)[source]
Bases:
psy_simple.plotters.VectorCalculator
Change the linewidth of the arrows
Possible types
float – give the linewidth explicitly
string {‘absolute’, ‘u’, ‘v’} – Strings may define how the formatoption is calculated. Possible strings are
absolute: for the absolute wind speed
u: for the u component
v: for the v component
tuple (string, float) – string may be one of the above strings, float may be a scaling factor
2D-array – The values determine the linewidth for each plotted arrow. Note that the shape has to match the one of u and v.
See also
arrowsize
,arrowstyle
,density
,color
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- name = 'Linewidth of the arrows'
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
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.VectorPlot(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Choose the vector plot type
Possible types
str – Plot types can be either
- quiver
to make a quiver plot
- stream
to make a stream plot
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Methods:
add2format_coord
(x, y)Additional information for the
format_coord()
get_xyz_1d
(xcoord, x, ycoord, y, u, v)Get closest x, y and z for the given x and y in data for 1d coords
get_xyz_2d
(xcoord, x, ycoord, y, u, v)Get closest x, y and z for the given x and y in data for 2d coords
get_xyz_tri
(xcoord, x, ycoord, y, u, v)Get closest x, y and z for the given x and y in data for 1d coords
remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
Attributes:
arrowsize Formatoption instance in the plotter
arrowstyle Formatoption instance in the plotter
bounds Formatoption instance in the plotter
list of str.
cmap Formatoption instance in the plotter
color Formatoption instance in the plotter
list of str.
bool
or a callable.density Formatoption instance in the plotter
The function that can replace the axes.format_coord method
str
.linewidth Formatoption instance in the plotter
The mappable, i.e. the container of the plot.
str
.bool
.int
.transform Formatoption instance in the plotter
transpose Formatoption instance in the plotter
The x coordinate
xarray.Variable
The y coordinate
xarray.Variable
- add2format_coord(x, y)[source]
Additional information for the
format_coord()
- property array
- property arrowsize
arrowsize Formatoption instance in the plotter
- property arrowstyle
arrowstyle Formatoption instance in the plotter
- property bounds
bounds Formatoption instance in the plotter
- children = ['cmap', 'bounds']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property cmap
cmap Formatoption instance in the plotter
- property color
color Formatoption instance in the plotter
- connections = ['transpose', 'transform', 'arrowsize', 'arrowstyle', 'density', 'linewidth', 'color']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- 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)
- property density
density Formatoption instance in the plotter
- property format_coord
The function that can replace the axes.format_coord method
- get_xyz_1d(xcoord, x, ycoord, y, u, v)[source]
Get closest x, y and z for the given x and y in data for 1d coords
- get_xyz_2d(xcoord, x, ycoord, y, u, v)[source]
Get closest x, y and z for the given x and y in data for 2d coords
- get_xyz_tri(xcoord, x, ycoord, y, u, v)[source]
Get closest x, y and z for the given x and y in data for 1d coords
- property linewidth
linewidth Formatoption instance in the plotter
- property mappable
The mappable, i.e. the container of the plot
- name = 'Plot type of the arrows'
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 = 20
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)
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- property transform
transform Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property xcoord
The x coordinate
xarray.Variable
- property ycoord
The y coordinate
xarray.Variable
- class psy_simple.plotters.ViolinPlot(*args, **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Choose how to make the violin plot
Possible types
None or False – Don’t make any plotting
bool – If True, visualize the violins
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
color Formatoption instance in the plotter
bool
or a callable.str
.str
.bool
.int
.transpose Formatoption instance in the plotter
Methods:
remove
()Method to remove the effects of this formatoption
update
(value)Method that is call to update the formatoption on the axes
- children = ['color', 'transpose']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property color
color Formatoption instance in the plotter
- 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)
- name = 'Violin plot type'
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 = 20
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)
- remove()[source]
Method to remove the effects of this formatoption
This method is called when the axes is cleared due to a formatoption with
requires_clearing
set to True. You don’t necessarily have to implement this formatoption if your plot results are removed by the usualmatplotlib.axes.Axes.clear()
method.
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.ViolinPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psy_simple.plotters.SimplePlotterBase
Plotter for making violin plots
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Axes formatoptions:
Color the x- and y-axes
The background color for the matplotlib axes.
Display the grid
Automatically adjust the plots.
Switch x- and y-axes
Set the x-axis limits
Set the y-axis limits
Color coding formatoptions:
Set the color coding
Label formatoptions:
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:
Draw a legend
Set the labels of the arrays in the legend
Make x- and y-axis symmetric
Change the ticksize of the ticklabels
Change the fontweight of the 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:
Choose how to make the violin plot
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoptionAxis tick formatoptions:
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 x-axis ticklabels
Specify the y-axis tick parameters
Modify the y-axis ticks
- 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
- color
Set the color coding
This formatoptions sets the color of the lines, bars, etc.
Possible types
None – to use the axes color_cycle
iterable – (e.g. list) to specify the colors manually
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 – to automatically choose the colors according to the number of lines, etc. from the given colormap
- 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()
functionNotes
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'
).
- 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
- legend
Draw a legend
This formatoption determines where and if to draw the legend. It uses the
labels
formatoption to determine the labels.Possible types
bool – Draw a legend or not
str or int – Specifies where to plot the legend (i.e. the location)
dict – Give the keywords for the
matplotlib.pyplot.legend()
function
See also
labels
- legendlabels
Set the labels of the arrays in the legend
This formatoption specifies the labels for each array in the legend. 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 – A single string that shall be used for all arrays.
list of str – Same as a single string but specified for each array
See also
- 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
- 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
- plot
Choose how to make the violin plot
Possible types
None or False – Don’t make any plotting
bool – If True, visualize the violins
- 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
See also
- yticklabels
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 integersarray – 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 necessarydict – 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_simple.plotters.ViolinXTickLabels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.XTickLabels
,psy_simple.base.TextBase
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 integersarray – An array of strings to use for the ticklabels
See also
xticks
,ticksize
,tickweight
,xtickprops
,yticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.transpose Formatoption instance in the plotter
xticks Formatoption instance in the plotter
yticklabels Formatoption instance in the plotter
Methods:
update_axis
(value)- 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)
- property transpose
transpose Formatoption instance in the plotter
- property xticks
xticks Formatoption instance in the plotter
- property yticklabels
yticklabels Formatoption instance in the plotter
- class psy_simple.plotters.ViolinXTicks(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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 necessarydict – 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
xticklabels
,ticksize
,tickweight
,xtickprops
,yticks
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
yticks Formatoption instance in the plotter
- property array
The numpy array of the data
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.ViolinXlim(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
plot Formatoption instance in the plotter
sym_lims Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xticks Formatoption instance in the plotter
ylim Formatoption instance in the plotter
- property array
The numpy array of the data
- property plot
plot Formatoption instance in the plotter
- property sym_lims
sym_lims Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xticks
xticks Formatoption instance in the plotter
- property ylim
ylim Formatoption instance in the plotter
- class psy_simple.plotters.ViolinYTickLabels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.YTickLabels
,psy_simple.base.TextBase
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 integersarray – An array of strings to use for the ticklabels
See also
xticks
,ticksize
,tickweight
,xtickprops
,yticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
bool
or a callable.transpose Formatoption instance in the plotter
yticks Formatoption instance in the plotter
Methods:
update_axis
(value)- 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)
- property transpose
transpose Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.ViolinYTicks(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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 necessarydict – 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).
See also
yticklabels
,ticksize
,tickweight
,ytickprops
xticks
for possible examples
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
- property array
The numpy array of the data
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.ViolinYlim(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
plot Formatoption instance in the plotter
sym_lims Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xlim Formatoption instance in the plotter
yticks Formatoption instance in the plotter
- property array
The numpy array of the data
- property plot
plot Formatoption instance in the plotter
- property sym_lims
sym_lims Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xlim
xlim Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.XRotation(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
See also
yrotation
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.str
.yticklabels Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- children = ['yticklabels']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- name = 'Rotate x-ticklabels'
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)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property yticklabels
yticklabels Formatoption instance in the plotter
- class psy_simple.plotters.XTickLabels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.TickLabels
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 integersarray – An array of strings to use for the ticklabels
See also
xticks
,ticksize
,tickweight
,xtickprops
,yticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The axis on the axes to modify the ticks of
list of str.
str
.transpose Formatoption instance in the plotter
xticks Formatoption instance in the plotter
yticklabels Formatoption instance in the plotter
Methods:
initialize_plot
(*args, **kwargs)Method that is called when the plot is made the first time
- property axis
The axis on the axes to modify the ticks of
- dependencies = ['transpose', 'xticks', 'yticklabels']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- initialize_plot(*args, **kwargs)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- name = 'x-xxis Ticklabels'
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
- property transpose
transpose Formatoption instance in the plotter
- property xticks
xticks Formatoption instance in the plotter
- property yticklabels
yticklabels Formatoption instance in the plotter
- class psy_simple.plotters.XTickProps(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.TickPropsBase
,psy_simple.plotters.TicksManager
,psyplot.plotter.DictFormatoption
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
,yticks
,ticksize
,tickweight
,ytickprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.- property axis
- axisname = 'x'
- class psy_simple.plotters.XTicks(*args, **kwargs)[source]
Bases:
psy_simple.plotters.DtTicksBase
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 necessarydict – 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
xticklabels
,ticksize
,tickweight
,xtickprops
,yticks
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
The data that is plotted
list of str.
str
.plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
yticks Formatoption instance in the plotter
Methods:
initialize_plot
(*args, **kwargs)Method that is called when the plot is made the first time
- property axis
- children = ['yticks']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property data
The data that is plotted
- dependencies = ['transpose', 'plot', 'plot']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- initialize_plot(*args, **kwargs)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- name = 'Location of the x-Axis ticks'
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
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.XTicks2D(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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 necessarydict – 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
xticklabels
,ticksize
,tickweight
,xtickprops
,yticks
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The data that is plotted
plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
yticks Formatoption instance in the plotter
- property data
The data that is plotted
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.XYTickPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)[source]
Bases:
psyplot.plotter.Plotter
Plotter class for x- and y-ticks and x- and y- ticklabels
- Parameters
data (InteractiveArray or ArrayList, optional) – Data object that shall be visualized. If given and plot is True, the
initialize_plot()
method is called at the end. Otherwise you can call this method later by yourselfax (matplotlib.axes.Axes) – Matplotlib Axes to plot on. If None, a new one will be created as soon as the
initialize_plot()
method is calledauto_update (bool) – Default: None. A boolean indicating whether this list shall automatically update the contained arrays when calling the
update()
method or not. See also theno_auto_update
attribute. If None, the value from the'lists.auto_update'
key in thepsyplot.rcParams
dictionary is used.draw (bool or None) – Boolean to control whether the figure of this array shall be drawn at the end. If None, it defaults to the ‘auto_draw’` parameter in the
psyplot.rcParams
dictionarymake_plot (bool) – If True, and data is not None, the plot is initialized. Otherwise only the framework between plotter and data is set up
clear (bool) – If True, the axes is cleared first
enable_post (bool) – If True, the
post
formatoption is enabled and post processing scripts are allowed**kwargs – Any formatoption key from the
formatoptions
attribute that shall be used
Label formatoptions:
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
Set the x-axis label
Set the y-axis label
Post processing formatoptions:
Apply your own postprocessing script
Determine when to run the
post
formatoptionMiscallaneous formatoptions:
Change the ticksize of the ticklabels
Change the fontweight of the ticks
Axes formatoptions:
Switch x- and y-axes
Axis tick formatoptions:
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
- 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
- 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
- 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
- transpose
Switch x- and y-axes
By default, one-dimensional arrays have the dimension on the x-axis and two dimensional arrays have the first dimension on the y and the second on the x-axis. You can set this formatoption to True to change this behaviour
Possible types
bool – If True, axes are switched
- 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
- xrotation
Rotate the x-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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
- yrotation
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
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 integersarray – 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 necessarydict – 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_simple.plotters.Xlabel(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.base.TextBase
,psyplot.plotter.Formatoption
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
The enhanced attributes of the array
str
.transpose Formatoption instance in the plotter
ylabel Formatoption instance in the plotter
Methods:
initialize_plot
(value)Method that is called when the plot is made the first time
update
(value)Method that is call to update the formatoption on the axes
- children = ['transpose', 'ylabel']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property enhanced_attrs
The enhanced attributes of the array
- initialize_plot(value)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- name = 'x-axis label'
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
- property transpose
transpose Formatoption instance in the plotter
- update(value)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property ylabel
ylabel Formatoption instance in the plotter
- class psy_simple.plotters.Xlim(*args, **kwargs)[source]
Bases:
psy_simple.plotters.LimitBase
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
list of str.
list of str.
list of str.
str
.plot Formatoption instance in the plotter
sym_lims Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xticks Formatoption instance in the plotter
ylim Formatoption instance in the plotter
Methods:
initialize_plot
(value)Method that is called when the plot is made the first time
set_limit
(*args)The method to set the minimum and maximum limit
- property array
The numpy array of the data
- axisname = 'x'
- children = ['transpose', 'ylim']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- connections = ['plot', 'sym_lims']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- dependencies = ['xticks']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- initialize_plot(value)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- name = 'x-axis limits'
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
- property plot
plot Formatoption instance in the plotter
- property sym_lims
sym_lims Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xticks
xticks Formatoption instance in the plotter
- property ylim
ylim Formatoption instance in the plotter
- class psy_simple.plotters.Xlim2D(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
plot Formatoption instance in the plotter
sym_lims Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xticks Formatoption instance in the plotter
ylim Formatoption instance in the plotter
- property array
The numpy array of the data
- property plot
plot Formatoption instance in the plotter
- property sym_lims
sym_lims Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xticks
xticks Formatoption instance in the plotter
- property ylim
ylim Formatoption instance in the plotter
- class psy_simple.plotters.YRotation(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psyplot.plotter.Formatoption
Rotate the y-axis ticks
Possible types
float – The rotation angle in degrees
See also
xrotation
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
str
.str
.yticklabels Formatoption instance in the plotter
Methods:
update
(value)Method that is call to update the formatoption on the axes
- children = ['yticklabels']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- name = 'Rotate y-ticklabels'
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)[source]
Method that is call to update the formatoption on the axes
- Parameters
value – Value to update
- property yticklabels
yticklabels Formatoption instance in the plotter
- class psy_simple.plotters.YTickLabels(*args, **kwargs)[source]
Bases:
psy_simple.plotters.TickLabels
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 integersarray – An array of strings to use for the ticklabels
See also
yticks
,ticksize
,tickweight
,ytickprops
,xticklabels
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The axis on the axes to modify the ticks of
list of str.
str
.transpose Formatoption instance in the plotter
yticks Formatoption instance in the plotter
- property axis
The axis on the axes to modify the ticks of
- dependencies = ['transpose', 'yticks']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'y-xxis ticklabels'
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
- property transpose
transpose Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.YTickProps(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.plotters.XTickProps
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
xticks
,yticks
,ticksize
,tickweight
,xtickprops
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
str
.- property axis
- axisname = 'y'
- class psy_simple.plotters.YTicks(*args, **kwargs)[source]
Bases:
psy_simple.plotters.DtTicksBase
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 necessarydict – 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).
See also
yticklabels
,ticksize
,tickweight
,ytickprops
xticks
for possible examples
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The data that is plotted
list of str.
str
.plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
- property axis
- property data
The data that is plotted
- dependencies = ['transpose', 'plot', 'plot']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'Location of the y-Axis ticks'
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
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.YTicks2D(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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 necessarydict – 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).
See also
yticklabels
,ticksize
,tickweight
,ytickprops
xticks
for possible examples
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The data that is plotted
plot Formatoption instance in the plotter
transpose Formatoption instance in the plotter
- property data
The data that is plotted
- property plot
plot Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.Ylabel(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)[source]
Bases:
psy_simple.base.TextBase
,psyplot.plotter.Formatoption
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
list of str.
The enhanced attributes of the array
str
.transpose Formatoption instance in the plotter
Methods:
initialize_plot
(value)Method that is called when the plot is made the first time
update
(value)Method that is call to update the formatoption on the axes
- children = ['transpose']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- property enhanced_attrs
The enhanced attributes of the array
- initialize_plot(value)[source]
Method that is called when the plot is made the first time
- Parameters
value – The value to use for the initialization
- name = 'y-axis label'
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
- property transpose
transpose Formatoption instance in the plotter
- class psy_simple.plotters.Ylim(*args, **kwargs)[source]
Bases:
psy_simple.plotters.LimitBase
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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
list of str.
list of str.
list of str.
str
.plot Formatoption instance in the plotter
sym_lims Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xlim Formatoption instance in the plotter
yticks Formatoption instance in the plotter
Methods:
set_limit
(*args)The method to set the minimum and maximum limit
- property array
The numpy array of the data
- axisname = 'y'
- children = ['transpose', 'xlim']
list of str. List of formatoptions that have to be updated before this one is updated. Those formatoptions are only updated if they exist in the update parameters.
- connections = ['plot', 'sym_lims']
list of str. Connections to other formatoptions that are (different from
dependencies
andchildren
) not important for the update process
- dependencies = ['yticks']
list of str. List of formatoptions that force an update of this formatoption if they are updated.
- name = 'y-axis limits'
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
- property plot
plot Formatoption instance in the plotter
- property sym_lims
sym_lims Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xlim
xlim Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- class psy_simple.plotters.Ylim2D(*args, **kwargs)[source]
Bases:
psy_simple.plotters.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
- Parameters
key (str) – formatoption key in the plotter
plotter (psyplot.plotter.Plotter) – Plotter instance that holds this formatoption. If None, it is assumed that this instance serves as a descriptor.
index_in_list (int or None) – The index that shall be used if the data is a
psyplot.InteractiveList
additional_children (list or str) – Additional children to use (see the
children
attribute)additional_dependencies (list or str) – Additional dependencies to use (see the
dependencies
attribute)**kwargs – Further keywords may be used to specify different names for children, dependencies and connection formatoptions that match the setup of the plotter. Hence, keywords may be anything of the
children
,dependencies
andconnections
attributes, with values being the name of the new formatoption in this plotter.
Attributes:
The numpy array of the data
plot Formatoption instance in the plotter
sym_lims Formatoption instance in the plotter
transpose Formatoption instance in the plotter
xlim Formatoption instance in the plotter
yticks Formatoption instance in the plotter
- property array
The numpy array of the data
- property plot
plot Formatoption instance in the plotter
- property sym_lims
sym_lims Formatoption instance in the plotter
- property transpose
transpose Formatoption instance in the plotter
- property xlim
xlim Formatoption instance in the plotter
- property yticks
yticks Formatoption instance in the plotter
- psy_simple.plotters.convert_radian(coord, *variables)[source]
Convert the given coordinate from radian to degree
- Parameters
coord (xr.Variable) – The variable to transform
*variables – The variables that are on the same unit.
- Returns
The transformed variable if one of the given variables has units in radian
- Return type
xr.Variable
- psy_simple.plotters.format_coord_func(ax, ref)[source]
Create a function that can replace the
matplotlib.axes.Axes.format_coord()
- Parameters
ax (matplotlib.axes.Axes) – The axes instance
ref (weakref.weakref) – The reference to the
Formatoption
instance
- Returns
The function that can be used to replace ax.format_coord
- Return type
function
- psy_simple.plotters.round_to_05(n, exp=None, mode='s')[source]
Round to the next 0.5-value.
This function applies the round function func to round n to the next 0.5-value with respect to its exponent with base 10 (i.e. 1.3e-4 will be rounded to 1.5e-4) if exp is None or with respect to the given exponent in exp.
- Parameters
n (numpy.ndarray) – number to round
exp (int or numpy.ndarray) – Exponent for rounding. If None, it will be computed from n to be the exponents for base 10.
mode ({'s', 'l'}) – rounding mode. If ‘s’, it will be rounded to value whose absolute value is below n, if ‘l’ it will rounded to the value whose absolute value is above n.
- Returns
rounded n
- Return type
Examples
The effects of the different parameters are show in the example below:
>>> from psyplot.plotter.simple import round_to_05 >>> a = [-100.3, 40.6, 8.7, -0.00023] >>>round_to_05(a, mode='s') array([ -1.00000000e+02, 4.00000000e+01, 8.50000000e+00, -2.00000000e-04]) >>> round_to_05(a, mode='l') array([ -1.50000000e+02, 4.50000000e+01, 9.00000000e+00, -2.50000000e-04])