Base formatoptions for psy-simple.

This module defines several formatoptions that are the basis for many matplotlib figures, such as axes title, figure title, etc.

Classes:

BackgroundColor(key[, plotter, ...])

The background color for the matplotlib axes.

BasePlotter([data, ax, auto_update, ...])

Base class with formatoptions for plotting on an matplotlib axes

Figtitle(key[, plotter, index_in_list, ...])

Plot a figure title

Mask(key[, plotter, index_in_list, ...])

Mask the data where a certain condition is True

MaskBetween(key[, plotter, index_in_list, ...])

Mask data points between two numbers

MaskGeq(key[, plotter, index_in_list, ...])

Mask data points greater than or equal to a number

MaskGreater(key[, plotter, index_in_list, ...])

Mask data points greater than a number

MaskLeq(key[, plotter, index_in_list, ...])

Mask data points smaller than or equal to a number

MaskLess(key[, plotter, index_in_list, ...])

Mask data points smaller than a number

Text(*args, **kwargs)

Add text anywhere on the plot

TextBase()

Abstract base class for formatoptions that provides a replace method

Tight(key[, plotter, index_in_list, ...])

Automatically adjust the plots.

Title(key[, plotter, index_in_list, ...])

Show the title

TitlesPlotter([data, ax, auto_update, ...])

Plotter class for labels

ValueMaskBase(key[, plotter, index_in_list, ...])

Base class for masking formatoptions

Functions:

label_props(base[, label_name, children, ...])

Function that returns a Formatoption class for modifying the fontsite

label_size(base[, label_name, children, ...])

Function that returns a Formatoption class for modifying the fontsite

label_weight(base[, label_name, children, ...])

Function that returns a Formatoption class for modifying the fontweight

class psy_simple.base.BackgroundColor(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: Formatoption

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

Methods:

get_fmt_widget(parent, project)

Get a widget to update the formatoption in the GUI

update(value)

Method that is call to update the formatoption on the axes

Attributes:

group

str.

name

str.

get_fmt_widget(parent, project)

Get a widget to update the formatoption in the GUI

This method should return a QWidget that is loaded by the psyplot-gui when the formatoption is selected in the psyplot_gui.main.Mainwindow.fmt_widget. It should call the insert_text() method when the update text for the formatoption should be changed.

Parameters:
  • parent (psyplot_gui.fmt_widget.FormatoptionWidget) – The parent widget that contains the returned QWidget

  • project (psyplot.project.Project) – The current subproject (see psyplot.project.gcp())

Returns:

The widget to control the formatoption

Return type:

PyQt5.QtWidgets.QWidget

group = 'axes'

str. Key of the group name in groups of this formatoption keyword

name = 'Background color of the 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

update(value)

Method that is call to update the formatoption on the axes

Parameters:

value – Value to update

class psy_simple.base.BasePlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)

Bases: TitlesPlotter

Base class with formatoptions for plotting on an matplotlib axes

Attributes:

background

The background color for the matplotlib axes.

mask

Mask the data where a certain condition is True

maskbetween

Mask data points between two numbers

maskgeq

Mask data points greater than or equal to a number

maskgreater

Mask data points greater than a number

maskleq

Mask data points smaller than or equal to a number

maskless

Mask data points smaller than a number

tight

Automatically adjust the plots.

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

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

maskgeq

Mask data points greater than or equal to a number

Possible types

float

The floating number to mask above

maskgreater

Mask data points greater than a number

Possible types

float

The floating number to mask above

maskleq

Mask data points smaller than or equal to a number

Possible types

float

The floating number to mask below

maskless

Mask data points smaller than a number

Possible types

float

The floating number to mask below

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!

class psy_simple.base.Figtitle(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: TextBase, Formatoption

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 the datetime.datetime.strftime() method as long as the data has a time coordinate and this can be converted to a datetime 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 are

    • tinfo: %H:%M

    • dtinfo: %B %d, %Y. %H:%M

    • dinfo: %B %d, %Y

    • desc: %(long_name)s [%(units)s]

    • sdesc: %(name)s [%(units)s]

Possible types

str

The title for the suptitle() function

Notes

  • If the plotter is part of a psyplot.project.Project and multiple plotters of this project are on the same figure, the replacement attributes (see above) are joined by a delimiter. If the delimiter attribute of this Figtitle 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

title, figtitlesize, figtitleweight, figtitleprops

Methods:

clear_other_texts([remove])

Make sure that no other text is a the same position as this one

initialize_plot(s)

Method that is called when the plot is made the first time

update(s)

Method that is call to update the formatoption on the axes

Attributes:

enhanced_attrs

The enhanced attributes of the array

name

str.

clear_other_texts(remove=False)

Make sure that no other text is a the same position as this one

This method clears all text instances in the figure that are at the same position as the _text attribute

Parameters:

remove (bool) – If True, the Text instances are permanently deleted from the figure, otherwise there text is simply set to ‘’

property enhanced_attrs

The enhanced attributes of the array

initialize_plot(s)

Method that is called when the plot is made the first time

Parameters:

value – The value to use for the initialization

name = 'Figure title'

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(s)

Method that is call to update the formatoption on the axes

Parameters:

value – Value to update

class psy_simple.base.Mask(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: Formatoption

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

Methods:

diff(value)

Checks whether the given value differs from what is currently set

load_mask(data, value)

update(value)

Method that is call to update the formatoption on the axes

Attributes:

group

str.

name

str.

priority

int.

diff(value)

Checks whether the given value differs from what is currently set

Parameters:

value – A possible value to set (make sure that it has been validate via the validate attribute before)

Returns:

True if the value differs from what is currently set

Return type:

bool

group = 'masking'

str. Key of the group name in groups of this formatoption keyword

load_mask(data, value)
name = 'Apply a mask'

str. A bit more verbose name than the formatoption key to be included in the gui. If None, the key is used in the gui

priority = 30

int. Priority value of the the formatoption determining when the formatoption is updated.

  • 10: at the end (for labels, etc.)

  • 20: before the plotting (e.g. for colormaps, etc.)

  • 30: before loading the data (e.g. for lonlatbox)

update(value)

Method that is call to update the formatoption on the axes

Parameters:

value – Value to update

class psy_simple.base.MaskBetween(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: ValueMaskBase

Mask data points between two numbers

Possible types

float

The floating number to mask above

See also

maskless, maskleq, maskgreater, maskgeq

Methods:

mask_func(data, value)

The masking function that is called

Attributes:

name

str.

mask_func(data, value)

The masking function that is called

name = 'Mask between two 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

class psy_simple.base.MaskGeq(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: ValueMaskBase

Mask data points greater than or equal to a number

Possible types

float

The floating number to mask above

See also

maskless, maskleq, maskgreater, maskbetween

Methods:

mask_func(data, value)

The masking function that is called

Attributes:

name

str.

mask_func(data, value)

The masking function that is called

name = 'Mask greater than or equal'

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.base.MaskGreater(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: ValueMaskBase

Mask data points greater than a number

Possible types

float

The floating number to mask above

See also

maskless, maskleq, maskgeq, maskbetween

Methods:

mask_func(data, value)

The masking function that is called

Attributes:

name

str.

mask_func(data, value)

The masking function that is called

name = 'Mask greater'

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.base.MaskLeq(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: ValueMaskBase

Mask data points smaller than or equal to a number

Possible types

float

The floating number to mask below

See also

maskless, maskgreater, maskgeq, maskbetween

Methods:

mask_func(data, value)

The masking function that is called

Attributes:

name

str.

mask_func(data, value)

The masking function that is called

name = 'Mask lesser than or equal'

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.base.MaskLess(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: ValueMaskBase

Mask data points smaller than a number

Possible types

float

The floating number to mask below

See also

maskleq, maskgreater, maskgeq, maskbetween

Methods:

mask_func(data, value)

The masking function that is called

Attributes:

name

str.

mask_func(data, value)

The masking function that is called

name = 'Mask less'

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.base.Text(*args, **kwargs)

Bases: TextBase, Formatoption

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 the datetime.datetime.strftime() method as long as the data has a time coordinate and this can be converted to a datetime 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 are

    • tinfo: %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., see matplotlib.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

See also

title, figtitle

Methods:

diff(value)

Checks whether the given value differs from what is currently set

finish_update()

Clears the _texts_to_remove set

remove()

Method to remove the effects of this formatoption

set_value(value[, validate, todefault])

Set (and validate) the value in the plotter.

share(fmto, **kwargs)

Share the settings of this formatoption with other data objects

update(value[, texts_to_remove])

Method that is call to update the formatoption on the axes

Attributes:

name

str.

transform

Dictionary containing the relevant transformations

diff(value)

Checks whether the given value differs from what is currently set

Parameters:

value – A possible value to set (make sure that it has been validate via the validate attribute before)

Returns:

True if the value differs from what is currently set

Return type:

bool

finish_update()

Clears the _texts_to_remove set

name = 'Arbitrary text on the 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

remove()

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 usual matplotlib.axes.Axes.clear() method.

set_value(value, validate=True, todefault=False)

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.

Parameters:
  • value – Value to set

  • validate (bool) – if True, validate the value before it is set

  • todefault (bool) – True if the value is updated to the default value

share(fmto, **kwargs)

Share the settings of this formatoption with other data objects

Parameters:
  • fmto (Formatoption) – The Formatoption instance to share the attributes with

  • **kwargs – Any other keyword argument that shall be passed to the update method of fmto

Notes

The Text formatoption sets the ‘texts_to_remove’ keyword to the _texts_to_remove attribute of this instance (if not already specified in **kwargs

property transform

Dictionary containing the relevant transformations

update(value, texts_to_remove=None)

Method that is call to update the formatoption on the axes

Parameters:

value – Value to update

class psy_simple.base.TextBase

Bases: object

Abstract base class for formatoptions that provides a replace method

Attributes:

data_dependent

delimiter

enhanced_attrs

The enhanced attributes of the array

group

rc

SubDict of rcParams 'texts' key

Methods:

get_enhanced_attrs(*args, **kwargs)

get_fig_data_attrs([delimiter])

Join the data attributes with other plotters in the project

get_fmt_widget(parent, project)

Create a combobox with the attributes

replace(s, data[, attrs])

Replace the attributes of the plotter data in a string

data_dependent = True
delimiter = None
property enhanced_attrs

The enhanced attributes of the array

get_enhanced_attrs(*args, **kwargs)
get_fig_data_attrs(delimiter=None)

Join the data attributes with other plotters in the project

This method joins the attributes of the InteractiveBase instances in the project that draw on the same figure as this instance does.

Parameters:

delimiter (str) – Specifies the delimiter with what the attributes are joined. If None, the delimiter attribute of this instance or (if the latter is also None), the rcParams[‘texts.delimiter’] item is used.

Returns:

A dictionary with all the meta attributes joined by the specified delimiter

Return type:

dict

get_fmt_widget(parent, project)

Create a combobox with the attributes

group = 'labels'
property rc

SubDict of rcParams ‘texts’ key

replace(s, data, attrs=None)

Replace the attributes of the plotter data in a string

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 the datetime.datetime.strftime() method as long as the data has a time coordinate and this can be converted to a datetime 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 are

    • tinfo: %H:%M

    • dtinfo: %B %d, %Y. %H:%M

    • dinfo: %B %d, %Y

    • desc: %(long_name)s [%(units)s]

    • sdesc: %(name)s [%(units)s]

Parameters:
  • s (str) – String where the replacements shall be made

  • data (InteractiveBase) – Data object from which to use the coordinates and insert the coordinate and attribute informations

  • attrs (dict) – Meta attributes that shall be used for replacements. If None, it will be gained from data.attrs

Returns:

s with inserted informations

Return type:

str

class psy_simple.base.Tight(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: Formatoption

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!

Attributes:

group

str.

name

str.

Methods:

update(value)

Method that is call to update the formatoption on the axes

group = 'axes'

str. Key of the group name in groups of this formatoption keyword

name = 'Tight layout'

str. A bit more verbose name than the formatoption key to be included in the gui. If None, the key is used in the gui

update(value)

Method that is call to update the formatoption on the axes

Parameters:

value – Value to update

class psy_simple.base.Title(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: TextBase, Formatoption

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 the datetime.datetime.strftime() method as long as the data has a time coordinate and this can be converted to a datetime 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 are

    • tinfo: %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

figtitle, titlesize, titleweight, titleprops

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

Attributes:

name

str.

initialize_plot(value)

Method that is called when the plot is made the first time

Parameters:

value – The value to use for the initialization

name = 'Axes title'

str. A bit more verbose name than the formatoption key to be included in the gui. If None, the key is used in the gui

update(value)

Method that is call to update the formatoption on the axes

Parameters:

value – Value to update

class psy_simple.base.TitlesPlotter(data=None, ax=None, auto_update=None, project=None, draw=False, make_plot=True, clear=False, enable_post=False, **kwargs)

Bases: Plotter

Plotter class for labels

Attributes:

figtitle

Plot a figure title

figtitleprops

Properties of the figure title

figtitlesize

Set the size of the figure title

figtitleweight

Set the fontweight of the figure title

text

Add text anywhere on the plot

title

Show the title

titleprops

Properties of the title

titlesize

Set the size of the title

titleweight

Set the fontweight of the title

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 the datetime.datetime.strftime() method as long as the data has a time coordinate and this can be converted to a datetime 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 are

    • tinfo: %H:%M

    • dtinfo: %B %d, %Y. %H:%M

    • dinfo: %B %d, %Y

    • desc: %(long_name)s [%(units)s]

    • sdesc: %(name)s [%(units)s]

Possible types

str

The title for the suptitle() function

Notes

  • If the plotter is part of a psyplot.project.Project and multiple plotters of this project are on the same figure, the replacement attributes (see above) are joined by a delimiter. If the delimiter attribute of this Figtitle 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.

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

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’.

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’.

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 the datetime.datetime.strftime() method as long as the data has a time coordinate and this can be converted to a datetime 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 are

    • tinfo: %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., see matplotlib.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

See also

title, figtitle

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 the datetime.datetime.strftime() method as long as the data has a time coordinate and this can be converted to a datetime 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 are

    • tinfo: %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.

titleprops

Properties of the title

Specify the font properties of the figure title manually.

Possible types

dict

Items may be any valid text property

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’.

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’.

class psy_simple.base.ValueMaskBase(key, plotter=None, index_in_list=None, additional_children=[], additional_dependencies=[], **kwargs)

Bases: Formatoption

Base class for masking formatoptions

Attributes:

data_dependent

bool or a callable.

group

str.

priority

int.

Methods:

mask_func()

The masking function that is called

update(value)

Method that is call to update the formatoption on the axes

data_dependent = True

bool or a callable. This attribute indicates whether this Formatoption 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)

group = 'masking'

str. Key of the group name in groups of this formatoption keyword

abstract mask_func()

The masking function that is called

priority = 30

int. Priority value of the the formatoption determining when the formatoption is updated.

  • 10: at the end (for labels, etc.)

  • 20: before the plotting (e.g. for colormaps, etc.)

  • 30: before loading the data (e.g. for lonlatbox)

update(value)

Method that is call to update the formatoption on the axes

Parameters:

value – Value to update

psy_simple.base.label_props(base, label_name=None, children=[], parents=[], dependencies=[])

Function that returns a Formatoption class for modifying the fontsite

This function returns a Formatoption instance that modifies the size of the given base formatoption

Parameters:
  • base (Formatoption) – The base formatoption instance that is used in the psyplot.Plotter subclass to create the label. The instance must have a texts attribute which stores all the matplotlib.text.Text instances.

  • label_name (str) – The name of the label to use in the documentation. If None, it will be key, where key is the psyplot.plotter.Formatoption.key` attribute of base

  • children (list of str) – The childrens of the resulting formatoption class (besides the base formatoption which is included anyway)

  • parents (list of str) – The parents of the resulting formatoption class (besides the base the properties formatoption from base (see label_props()))

  • dependencies (list of str) – The dependencies of the formatoption

  • children – The childrens of the resulting formatoption class (besides the base formatoption, the base.key + 'size' and base.key + 'weight' keys, which are included anyway (see label_size(), label_weight()))

  • parents – The parents of the resulting formatoption class

Returns:

The formatoption instance that modifies the fontsize of base

Return type:

Formatoption

psy_simple.base.label_size(base, label_name=None, children=[], parents=[], dependencies=[])

Function that returns a Formatoption class for modifying the fontsite

This function returns a Formatoption instance that modifies the size of the given base formatoption

Parameters:
  • base (Formatoption) – The base formatoption instance that is used in the psyplot.Plotter subclass to create the label. The instance must have a texts attribute which stores all the matplotlib.text.Text instances.

  • label_name (str) – The name of the label to use in the documentation. If None, it will be key, where key is the psyplot.plotter.Formatoption.key` attribute of base

  • children (list of str) – The childrens of the resulting formatoption class (besides the base formatoption which is included anyway)

  • parents (list of str) – The parents of the resulting formatoption class (besides the base the properties formatoption from base (see label_props()))

  • dependencies (list of str) – The dependencies of the formatoption

Returns:

The formatoption instance that modifies the fontsize of base

Return type:

Formatoption

psy_simple.base.label_weight(base, label_name=None, children=[], parents=[], dependencies=[])

Function that returns a Formatoption class for modifying the fontweight

This function returns a Formatoption instance that modifies the weight of the given base formatoption

Parameters:
  • base (Formatoption) – The base formatoption instance that is used in the psyplot.Plotter subclass to create the label. The instance must have a texts attribute which stores all the matplotlib.text.Text instances.

  • label_name (str) – The name of the label to use in the documentation. If None, it will be key, where key is the psyplot.plotter.Formatoption.key` attribute of base

  • children (list of str) – The childrens of the resulting formatoption class (besides the base formatoption which is included anyway)

  • parents (list of str) – The parents of the resulting formatoption class (besides the base the properties formatoption from base (see label_props()))

  • dependencies (list of str) – The dependencies of the formatoption

Returns:

The formatoption instance that modifies the fontweight of base

Return type:

Formatoption