Graphs and plotting#

Isotherm plotting#

Functions for plotting and comparing isotherms.

pygaps.graphing.isotherm_graphs.plot_iso(isotherms, ax=None, x_data: str = 'pressure', y1_data: str = 'loading', y2_data: str = None, branch: str = 'all', x_range: Tuple[float, float] = (None, None), y1_range: Tuple[float, float] = (None, None), y2_range: Tuple[float, float] = (None, None), x_points: Iterable[float] = None, y1_points: Iterable[float] = None, material_basis: str = None, material_unit: str = None, loading_basis: str = None, loading_unit: str = None, pressure_mode: str = None, pressure_unit: str = None, logx: bool = False, logy1: bool = False, logy2: bool = False, color: bool | str | Iterable[str] = True, marker: bool | str | Iterable[str] = True, y1_line_style: dict = None, y2_line_style: dict = None, lgd_keys: list = None, lgd_pos: str = 'best', save_path: str = None)[source]#

Plot the isotherm(s) provided on a single graph.

Parameters:
  • isotherms (PointIsotherms or list of Pointisotherms) -- An isotherm or iterable of isotherms to be plotted.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

  • x_data (str) -- Key of data to plot on the x axis. Defaults to 'pressure'.

  • y1_data (tuple) -- Key of data to plot on the left y axis. Defaults to 'loading'.

  • y2_data (tuple) -- Key of data to plot on the right y axis. Defaults to None.

  • branch (str) -- Which branch to display, adsorption ('ads'), desorption ('des'), or both ('all').

  • x_range (tuple) -- Range for data on the x axis. eg: (0, 1). Is applied to each isotherm, in the unit/mode/basis requested.

  • y1_range (tuple) -- Range for data on the regular y axis. eg: (0, 1). Is applied to each isotherm, in the unit/mode/basis requested.

  • y2_range (tuple) -- Range for data on the secondary y axis. eg: (0, 1). Is applied to each isotherm, in the unit/mode/basis requested.

  • x_points (tuple) -- Specific points of pressure where to evaluate an isotherm. Assumes x=pressure.

  • y1_points (tuple) -- Specific points of loading where to evaluate an isotherm. Assumes y1=loading.

  • material_basis (str, optional) -- Whether the adsorption is read in terms of either 'per volume' or 'per mass'.

  • material_unit (str, optional) -- Unit of loading, otherwise first isotherm value is used.

  • loading_basis (str, optional) -- Loading basis, otherwise first isotherm value is used.

  • loading_unit (str, optional) -- Unit of loading, otherwise first isotherm value is used.

  • pressure_mode (str, optional) -- The pressure mode, either absolute pressures or relative in the form of p/p0, otherwise first isotherm value is used.

  • pressure_unit (str, optional) -- Unit of pressure, otherwise first isotherm value is used.

  • logx (bool) -- Whether the graph x axis should be logarithmic.

  • logy1 (bool) -- Whether the graph y1 axis should be logarithmic.

  • logy2 (bool) -- Whether the graph y2 axis should be logarithmic.

  • color (bool, int, list, optional) -- If a boolean, the option controls if the graph is coloured or grayscale. Grayscale graphs are usually preferred for publications or print media. Otherwise, give a list of matplotlib colours or a number of colours to repeat in the cycle.

  • marker (bool, int, list, optional) -- Whether markers should be used to denote isotherm points. If an int, it will be the number of markers used. Otherwise, give a list of matplotlib markers or a number of markers to repeat in the cycle.

  • y1_line_style (dict) -- A dictionary that will be passed into the matplotlib plot() function. Applicable for left axis.

  • y2_line_style (dict) -- A dictionary that will be passed into the matplotlib plot() function. Applicable for right axis.

  • lgd_keys (iterable) -- The components of the isotherm which are displayed on the legend. For example pass ['material', 'adsorbate'] to have the legend labels display only these two components. Works with any isotherm properties and with 'branch' and 'key', the isotherm branch and the y-axis key respectively. Defaults to 'material' and 'adsorbate'.

  • lgd_pos ([None, Matplotlib legend classifier, 'out bottom', 'out top', 'out left', out right]) -- Specify to have the legend position outside the figure (out...) or inside the plot area itself (as determined by Matplotlib). Defaults to 'best'.

  • save_path (str, optional) -- Whether to save the graph or not. If a path is provided, then that is where the graph will be saved.

Returns:

axes (matplotlib.axes.Axes or numpy.ndarray of them)

Characterisation plotting#

Functions for plotting calculation-specific graphs.

pygaps.graphing.calc_graphs.roq_plot(pressure: Iterable[float], roq_points: Iterable[float], minimum: int, maximum: int, p_monolayer: float, roq_monolayer: float, ax=None)[source]#

Draw a Rouquerol plot.

Parameters:
  • pressure (array) -- Pressure points which will make up the x axis.

  • roq_points (array) -- Rouquerol-transformed points which will make up the y axis.

  • minimum (int) -- Lower bound of the selected points.

  • maximum (int) -- Higher bound of the selected points.

  • p_monolayer (float) -- Pressure at which statistical monolayer is achieved.

  • rol_monolayer (float) -- Rouquerol transform of the point at which statistical monolayer is achieved.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

matplotlib.axes -- Matplotlib axes of the graph generated. The user can then apply their own styling if desired.

pygaps.graphing.calc_graphs.bet_plot(pressure: Iterable[float], bet_points: Iterable[float], minimum: int, maximum: int, slope: float, intercept: float, p_monolayer: float, bet_monolayer: float, ax=None)[source]#

Draw a BET plot.

Parameters:
  • pressure (array) -- Pressure points which will make up the x axis.

  • bet_points (array) -- BET-transformed points which will make up the y axis.

  • minimum (int) -- Lower bound of the selected points.

  • maximum (int) -- Higher bound of the selected points.

  • slope (float) -- Slope of the chosen linear region.

  • intercept (float) -- Intercept of the chosen linear region.

  • p_monolayer (float) -- Pressure at which statistical monolayer is achieved.

  • rol_monolayer (float) -- BET transform of the point at which statistical monolayer is achieved.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

matplotlib.axes -- Matplotlib axes of the graph generated. The user can then apply their own styling if desired.

pygaps.graphing.calc_graphs.langmuir_plot(pressure: Iterable[float], langmuir_points: Iterable[float], minimum: int, maximum: int, slope: float, intercept: float, ax=None)[source]#

Draw a Langmuir plot.

Parameters:
  • pressure (array) -- Pressure points which will make up the x axix.

  • langmuir_points (array) -- Langmuir-transformed points which will make up the y axis.

  • minimum (int) -- Lower bound of the selected points.

  • maximum (int) -- Higher bound of the selected points.

  • slope (float) -- Slope of the chosen linear region.

  • intercept (float) -- Intercept of the chosen linear region.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

matplotlib.axes -- Matplotlib axes of the graph generated. The user can then apply their own styling if desired.

pygaps.graphing.calc_graphs.tp_plot(thickness_curve: Iterable[float], loading: Iterable[float], results: dict, units: dict, alpha_s: bool = False, alpha_reducing_p: float = None, ax=None)[source]#

Draw a t-plot (also used for the alpha-s plot).

Parameters:
  • thickness_curve (array) -- Thickness of the adsorbed layer at selected points. In the case of alpha_s plot, it is the alpha_s transform of the reference isotherm.

  • loading (array) -- Loading of the isotherm to plot.

  • results (dict) -- Dictionary of linear regions selected with the members:

    • section (array) : the points of the plot chosen for the line

    • area (float) : calculated surface area, from the section parameters

    • adsorbed_volume (float) : the amount adsorbed in the pores as calculated per section

    • slope (float) : slope of the straight trendline fixed through the region

    • intercept (float) : intercept of the straight trendline through the region

    • corr_coef (float) : correlation coefficient of the linear region

  • units (dict) -- A unit dictionary to fill in labels.

  • alpha_s (bool) -- Whether the function is used for alpha_s display.

  • alpha_reducing_p (float) -- The reducing pressure used for alpha_s.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

matplotlib.axes -- Matplotlib axes of the graph generated. The user can then apply their own styling if desired.

pygaps.graphing.calc_graphs.psd_plot(pore_widths: Iterable[float], pore_dist: Iterable[float], pore_vol_cum: Iterable[float] = None, method: str = None, labeldiff: str = 'distribution', labelcum: str = 'cumulative', log: bool = True, right: int = None, left: int = None, ax=None)[source]#

Draw a pore size distribution plot.

Parameters:
  • pore_widths (array) -- Array of the pore radii which will become the x axis.

  • pore_dist (array) -- Contribution of each pore radius which will make up the y axis.

  • pore_vol_cum (array) -- Pre-calculated cumulative value.

  • method (str) -- The method used. Will be a string part of the title.

  • labeldiff (str) -- The label for the plotted data, which will appear in the legend.

  • labelcum (str, optional) -- The label for the cumulative data, which will appear in the legend. Set to None to remove cumulative distribution

  • log (bool) -- Whether to display a logarithmic graph.

  • right (int) -- Higher bound of the selected pore widths.

  • right (int) -- Lower bound of the selected pore widths.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

matplotlib.axes -- Matplotlib axes of the graph generated. The user can then apply their own styling if desired.

pygaps.graphing.calc_graphs.isosteric_enthalpy_plot(loading: Iterable[float], isosteric_enthalpy: Iterable[float], std_err: Iterable[float], units: dict, log: bool = False, ax=None)[source]#

Draws the isosteric enthalpy plot.

Parameters:
  • loading (array) -- Loadings for which the isosteric enthalpy was calculated.

  • isosteric_enthalpy (array) -- The isosteric enthalpy corresponding to each loading.

  • std_err (array) -- Standard error for each point.

  • units (dict) -- A unit dictionary to fill in labels.

  • log (int) -- Whether to display a logarithmic graph.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

matplotlib.axes -- Matplotlib axes of the graph generated. The user can then apply their own styling if desired.

pygaps.graphing.calc_graphs.initial_enthalpy_plot(loading: Iterable[float], enthalpy: Iterable[float], fitted_enthalpy: Iterable[float], log: bool = False, title: str = None, extras=None, ax=None)[source]#

Draws the initial enthalpy calculation plot.

Parameters:
  • loading (array) -- Loadings for which the initial enthalpy was calculated.

  • enthalpy (array) -- The enthalpy corresponding to each loading.

  • fitted_enthalpy (array) -- The predicted enthalpy corresponding to each loading.

  • log (int) -- Whether to display a logarithmic graph

  • title (str) -- Name of the material to put in the title.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

matplotlib.axes -- Matplotlib axes of the graph generated. The user can then apply their own styling if desired.

pygaps.graphing.calc_graphs.dra_plot(logv: Iterable[float], log_n_p0p: Iterable[float], minimum: int, maximum: int, slope: float, intercept: float, exp: float, ax=None)[source]#

Draw a Dubinin plot.

Parameters:
  • logv (array) -- Logarithm of volume adsorbed.

  • log_n_p0p (array) -- Logarithm of pressure term.

  • minimum (int) -- Lower index of the selected points.

  • maximum (int) -- Higher index of the selected points.

  • slope (float) -- Slope of the fitted line.

  • intercept (float) -- Intercept of the fitted line.

  • exp (float) -- The exponent of the DA/DR graph.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

matplotlib.axes -- Matplotlib axes of the graph generated. The user can then apply their own styling if desired.

pygaps.graphing.calc_graphs.virial_plot(loading: Iterable[float], ln_p_over_n: Iterable[float], n_load: Iterable[float], p_load: Iterable[float], added_point: bool, ax=None)[source]#

Draw a Virial plot.

Model fitting plots#

pygaps.graphing.model_graphs.plot_model_guesses(attempts, pressure, loading)[source]#

Plot one or more isotherm model fits.

IAST plotting#

Functions for plotting graphs related to IAST calculations.

pygaps.graphing.iast_graphs.plot_iast(p_data: list, l_data: list, ads: list, p_label: str, l_label: str, ax=None)[source]#

Plot uptake-vs-pressure graph from IAST data.

Parameters:
  • p_data (array or list) -- The pressures at which uptakes are calculated.

  • l_data (2D array or list of lists) -- Uptake for each component a function of pressure.

  • ads (list[str]) -- Names of the adsorbates.

  • p_unit (str) -- Unit of pressure, for axis labelling.

  • l_unit (str) -- Unit of loading, for axis labelling.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

ax (matplotlib ax) -- The ax object.

pygaps.graphing.iast_graphs.plot_iast_vle(x_data: list, y_data: list, ads1: str, ads2: str, pressure: float, p_unit: str, ax=None)[source]#

Plot a vapour-adsorbed equilibrium graph from IAST data.

Parameters:
  • x_data (array or list) -- The molar fraction in the adsorbed phase.

  • y_data (array or list) -- The molar fraction in the gas phase.

  • ads1 (str) -- Name of the adsorbate which is regarded as the main component.

  • ads2 (str) -- Name of the adsorbate which is regarded as the secondary component.

  • pressure (float) -- Pressure at which the vle is plotted.

  • p_unit (str) -- Pressure unit, for labelling.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

ax (matplotlib ax) -- The ax object.

pygaps.graphing.iast_graphs.plot_iast_svp(p_data: list, s_data: list, ads1: str, ads2: str, fraction: float, p_unit: str, ax=None)[source]#

Plot a selectivity-vs-pressure graph from IAST data.

Parameters:
  • p_data (array or list) -- The pressures at which selectivity is calculated.

  • s_data (array or list) -- The selectivity towards the main component as a function of pressure.

  • ads1 (str) -- Name of the adsorbate which is regarded as the main component.

  • ads2 (str) -- Name of the adsorbate which is regarded as the secondary component.

  • fraction (float) -- Molar fraction of the main component in the mixture.

  • p_unit (str) -- Unit of the pressure, for axis labelling.

  • ax (matplotlib axes object, default None) -- The axes object where to plot the graph if a new figure is not desired.

Returns:

ax (matplotlib ax) -- The ax object.

Default matplotlib styles#

Contains global style dictionaries for matplotlib to be applied.

pygaps.graphing.mpl_styles.ISO_MARKERS: tuple[str] = ('o', 's', 'D', 'P', '*', '<', '>', 'X', 'v', '^')#

Markers used in plotting.

pygaps.graphing.mpl_styles.Y1_COLORS: tuple[str] = ('#003f5c', '#58508d', '#bc5090', '#ff6361', '#ffa600')#

Colors used in main (y1) plotting.

pygaps.graphing.mpl_styles.Y2_COLORS: tuple[str] = ('#0082bd', '#8674c5', '#d15d9e', '#ea5e59', '#ca8300')#

Colors used in secondary (y2) plotting.

pygaps.graphing.mpl_styles.BASE_STYLE: dict[str, t.Any] = {'legend.frameon': False}#

Style applied to ALL matplotlib figures in pygaps.

pygaps.graphing.mpl_styles.ISO_STYLE: dict[str, t.Any] = {'axes.labelsize': 15, 'axes.titlesize': 20, 'axes.titley': 1.01, 'figure.figsize': (6, 6), 'image.aspect': 'equal', 'legend.fontsize': 11, 'legend.handlelength': 2, 'lines.linewidth': 1.5, 'lines.markersize': 5, 'xtick.labelsize': 13, 'ytick.labelsize': 13}#

Style applied to Isotherm figures.

pygaps.graphing.mpl_styles.POINTS_MUTED: dict[str, t.Any] = {'lines.linestyle': 'none', 'lines.marker': 'o', 'lines.markeredgecolor': 'grey', 'lines.markeredgewidth': 1.5, 'lines.markerfacecolor': 'none', 'lines.markersize': 5}#

Style component to generate "muted/unselected" points.

pygaps.graphing.mpl_styles.POINTS_HIGHLIGHTED: dict[str, t.Any] = {'lines.linestyle': 'none', 'lines.marker': 'o', 'lines.markeredgecolor': 'r', 'lines.markerfacecolor': 'r', 'lines.markersize': 5}#

Style component to generate "highlighted/elected" points.

pygaps.graphing.mpl_styles.POINTS_IMPORTANT: dict[str, t.Any] = {'lines.linestyle': 'none', 'lines.marker': 'X', 'lines.markeredgecolor': 'k', 'lines.markerfacecolor': 'k', 'lines.markersize': 10}#

Style component to generate "single important" points.

pygaps.graphing.mpl_styles.LINE_FIT: dict[str, t.Any] = {'lines.linestyle': '--', 'lines.marker': ''}#

Style component to generate a line fitted through points.

pygaps.graphing.mpl_styles.LINE_ERROR: dict[str, t.Any] = {'lines.linestyle': '--', 'lines.marker': 'o', 'lines.markersize': 3}#

Style component to apply to error bars.