Main plotting function

This is the main plotting function for visualisation of results from models computed with the hoggorm package. All convenience functions make use of the main plotting function.

hoggormplot.main_plot.plot(model, comp=[1, 2], plots=[1, 2, 3, 4], which=[], line=False, weights=False, cumulative=True, individual=False, validated=[], objNames=[], XvarNames=[], YvarNames=[], newX=[], newY=[], newObjNames=[], figsize=None)

This is the main plot function that generates plots that visualise results from PCA, PCR, PLSR and PLSR2 models computed with the Hoggorm package.

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].
  • plots (list, optional) –

    Integers in this list define which plots are to be generated (combined in a single figure). The list defaults to [1, 2, 3, 4]. The following options are available:

    • 1 : Scores (default: X)
    • 2 : Loadings (default: X)
    • 3 : Correlation loadings (default: Both (X & Y))
    • 4 : Biplot (default: X)
    • 5 : Regression coefficients
    • 6 : Explained variance (default: Y)
    • 7 : Prediction

    Instead of integers, string arguments may be useds. The following options are available:

    • 'scores'
    • 'loadings'
    • 'correlationLoadings'
    • ' biplot'
    • 'coeffs'
    • 'explainedVariance'
    • 'predict'
  • 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.
  • 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).
  • 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:

Multiple plots.

Examples

>>> import hoggorm as ho
>>> import hoggormplot as hopl
>>> myModel = ho.nipalsPLS2(arrX=my_X_data, arrY=my_Y_data, cvType=["loo"])
>>> hopl.plot(myModel, plots=[1, 2, 3, 6], cumulative=True, line=True)
>>> hopl.plot(myModel)
>>> hopl.plot(myModel, plots=['scores', 'loadings', 'explainedVariance'], cumulative=True)