Convenience plotting functions

This is an overview of available convenience plotting functions in hoggormplot. They are based on the main plot function hoggorm.main_plot.plot and provide simplified interfaces for interactive use.

Explained variance plot

Note

The two functions below, i.e. .explVar and .explainedVariance are two options of how to generate explained variance plots. They generate identical plots when provided the same input parameters or arguments.

hoggormplot.conv_explainedVariancePlot.explVar(model, which=[], cumulative=True, individual=False, validated=[], figsize=None)

This function generates explained variances plots of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm.) –
  • which (list, optional) –

    This list may contain one string argument. The following options are available:

    • 'X'
    • 'Y'
    • 'Both' (defaults listed with ‘plots’ parameter)
  • cumulative (boolean, optional) – When set to 'cumulative=TRUE' explained variances will be plotted cumulatively instead of per component.
  • individual (boolean, optional) – When set to 'individual=TRUE' explained variances will be plotted per variable instead of for all variables together.
  • validated (list, optional) – When set to 'validated=[TRUE]' validated values are plotted if applicable (scores => False, explainedVariance => True).
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

An explained variance plot based on the input Hoggorm model.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.explVar(myModel, which=['Both'], individual=False)
>>> hopl.explVar(myModel)
>>> hopl.explVar(myModel, cumulative=True)
hoggormplot.conv_explainedVariancePlot.explainedVariance(model, which=[], cumulative=True, individual=False, validated=[], figsize=None)

This function generates explained variances plots of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm.) –
  • which (list, optional) –

    This list may contain one string argument. The following options are available:

    • 'X'
    • 'Y'
    • 'Both' (defaults listed with ‘plots’ parameter)
  • cumulative (boolean, optional) – When set to 'cumulative=TRUE' explained variances will be plotted cumulatively instead of per component.
  • individual (boolean, optional) – When set to 'individual=TRUE' explained variances will be plotted per variable instead of for all variables together.
  • validated (list, optional) – When set to 'validated=[TRUE]' validated values are plotted if applicable (scores => False, explainedVariance => True).
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

An explained variance plot based on the input Hoggorm model.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.explainedVariance(myModel, which=['Both'], individual=False)
>>> hopl.explainedVariance(myModel)
>>> hopl.explainedVariance(myModel, cumulative=True)

Scores plot

hoggormplot.conv_scoresPlot.scores(model, comp=[1, 2], which=[], objNames=[], newX=[], newY=[], newObjNames=[], figsize=None)

This is a convenience function that generates scores plots of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm) – The statistical results of the submitted model will be visualized.
  • comp (list, optional) – The list contains components to be displayed. Defaults to [1,2].
  • which (list, optional) –

    This list may contain one string argument. The following options are available:

    • 'X'
    • 'Y'
    • 'Both' (defaults listed with ‘plots’ parameter)
  • objNames (list, optional) – Object names may be provided in this list.
  • newX (list, optional) – The list contains one array of new measurement data X.
  • newY (list, optional) – The list contains one array of new measurements of Y.
  • newObjNames (list, optional) – The list contains object names of new measurement data in X or Y.
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

A scores plot.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.scores(myModel, comp=[1, 3])
>>> hopl.scores(myModel)

Loadings plot

hoggormplot.conv_loadingsPlot.loadings(model, comp=[1, 2], which=[], line=False, weights=False, XvarNames=[], YvarNames=[], figsize=None)

This is a convenience function that generates loadings plots of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm) – The statistical results of the submitted model will be visualized.
  • comp (list, optional) – The list contains components to be displayed. Defaults to [1,2].
  • which (list, optional) –

    This list may contain one string argument. The following options are available:

    • 'X'
    • 'Y'
    • 'Both' (defaults listed with ‘plots’ parameter)
  • line (boolean, optional) – When set to 'line=TRUE' loadings (weights) will be plotted as lines / spectra instead of as points in a scatter plot.
  • weights (boolean, optional) – When set to 'weights=TRUE' loading weights will be plotted instead of loadings.
  • XvarNames (list, optional) – Names of variables in array X may be provided in this list.
  • YvarNames (list, optional) – Names of variables in Y may be provided in this list.
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

A loadings plot.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.loadings(myModel, comp=[2,4], which=['Both'])
>>> hopl.loadings(myModel)
>>> hopl.loadings(myModel, line=True, weights=False)

Correlation loadings plot

hoggormplot.conv_correlationLoadingsPlot.correlationLoadings(model, comp=[1, 2], which=[], XvarNames=[], YvarNames=[], figsize=None)

This is a convenience plot function which generates correlation loadings plots of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm) – The statistical results of the submitted model will be visualized.
  • comp (list, optional) – The list contains components to be displayed. Defaults to [1,2].
  • which (list, optional) –

    This list may contain one string argument. The following options are available:

    • 'X'
    • 'Y'
    • 'Both' (defaults listed with ‘plots’ parameter)
  • XvarNames (list, optional) – Names of variables in array X may be provided in this list.
  • YvarNames (list, optional) – Names of variables in Y may be provided in this list.
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

A correlation loadings plot based on the input hoggorm model.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.correlationLoadings(myModel, comp=[2,4], which=['Both'])
>>> hopl.correlationLoadings(myModel)

Biplot

hoggormplot.conv_biPlot.biplot(model, comp=[1, 2], which=[], objNames=[], XvarNames=[], YvarNames=[], figsize=None)

This is a convenience plot function which generates a bi-plot of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm.) –
  • comp (list, optional) – The list contains components to be displayed. Defaults to [1,2].
  • which (list, optional) –

    This list may contain one string argument. The following options are available:

    • 'X'
    • 'Y'
    • 'Both' (defaults listed with ‘plots’ parameter)
  • objNames (list, optional) – Object names may be provided in this list.
  • XvarNames (list, optional) – Names of variables in array X may be provided in this list.
  • YvarNames (list, optional) – Names of variables in Y may be provided in this list.
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

A bi-plot based on the input hoggorm model.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.biplot(myModel, comp=[2, 4], which=['Both'])
>>> hopl.biplot(myModel)

Coefficients plot

Note

The two functions below, i.e. .coeff and .coefficients are two options of how to generate explained variance plots. They generate identical plots when provided the same input parameters or arguments.

hoggormplot.conv_coefficientsPlot.coefficients(model, comp=[1], figsize=None)

This is a convenience plot function which generates coefficients plots of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm) –
  • comp (list, optional) – The list contains components to be displayed. Defaults to [1].
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

A coefficients plot based on the input Hoggorm model.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.coefficients(myModel, comp=[1, 2, 3])
>>> hopl.coefficients(myModel)
>>> hopl.coefficients(myModel, comp=[2])
hoggormplot.conv_coefficientsPlot.coeffs(model, comp=[1], figsize=None)

This is a convenience plot function which generates coefficients plots of hoggorm models. Note that this convenience function is identical to hoggorm.resPlotting.coefficients.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm) –
  • comp (list, optional) – The list contains components to be displayed. Defaults to [1].
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

A coefficients plot based on the input Hoggorm model.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.coeffs(myModel, comp=[1, 2, 3])
>>> hopl.coeffs(myModel)
>>> hopl.coeffs(myModel, comp=[2])

Loading weights plot

hoggormplot.conv_loadingWeightsPlot.loadingWeights(model, comp=[1, 2], which=[], line=False, weights=True, XvarNames=[], YvarNames=[], figsize=None)

This is a convenience function that generates loading weights plots of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm) – The statistical results of the submitted model will be visualized.
  • comp (list, optional) – The list contains components to be displayed. Defaults to [1,2].
  • which (list, optional) –

    This list may contain one string argument. The following options are available:

    • 'X'
    • 'Y'
    • 'Both' (defaults listed with ‘plots’ parameter)
  • line (boolean, optional) – When set to 'line=TRUE' loadings (weights) will be plotted as lines / spectra instead of as points in a scatter plot.
  • weights (boolean, optional) – When set to 'weights=TRUE' loading weights will be plotted instead of loadings.
  • XvarNames (list, optional) – Names of variables in array X may be provided in this list.
  • YvarNames (list, optional) – Names of variables in Y may be provided in this list.
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

A loadings weights plot.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.loadingWeights(myModel, comp=[2,4], which=['Both'])
>>> hopl.loadingWeights(myModel)
>>> hopl.loadingWeights(myModel, line=True, weights=True)

Predict plot

hoggormplot.conv_predictPlot.predict(model, comp=[1, 2], objNames=[], newX=[], newY=[], newObjNames=[], figsize=None)

This is a convenience function that generates plots of predicted vs. original values of hoggorm models.

Parameters:
  • model (nipalsPCR/nipalsPLSR1/nipalsPLSR2 class object computed in Hoggorm) – The statistical results of the submitted model will be visualized.
  • comp (list, optional) – The list contains components to be displayed. Defaults to [1,2].
  • newX (list, optional) – The list contains one array of new measurement data X.
  • newY (list, optional) – The list contains one array of new measurements of Y.
  • newObjNames (list, optional) – The list contains object names of new measurement data in X or Y.
  • figsize (tuple, optional) – Sets figure width and height in inches
Returns:

Return type:

A predicted vs. measured plot.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.predict(myModel)
>>> hopl.predict(myModel, comp=[3, 4])