Additional plot utilities.

watex.utils.plotutils.confidence_ellipse(x, y, ax, n_std=3.0, facecolor='none', **kwargs)[source]#

Create a plot of the covariance confidence ellipse of x and y.

Parameters:
  • x (array-like, shape (n, )) – Input data.

  • y (array-like, shape (n, )) – Input data.

  • ax (matplotlib.axes.Axes) – The axes object to draw the ellipse into.

  • n_std (float) – The number of standard deviations to determine the ellipse’s radiuses.

  • **kwargs – Forwarded to ~matplotlib.patches.Ellipse

Return type:

mpl.patches.Ellipse

watex.utils.plotutils.controle_delineate_curve(res_deline=None, phase_deline=None)[source]#

fonction to controle delineate value given and return value ceilling .

Parameters:
  • res_deline (float|int|list) – resistivity value todelineate. unit of Res in ohm.m

  • phase_deline (float|int|list) – phase value to delineate , unit of phase in degree

Returns:

delineate resistivity or phase values

Return type:

array_like

watex.utils.plotutils.fmt_text(data_text, fmt='~', leftspace=3, return_to_line=77)[source]#

Allow to format report with data text , fm and leftspace

Parameters:
  • data_text (str) – a long text

  • fmt (str) – type of underline text

  • leftspae (int) – How many space do you want before starting wrinting report .

  • return_to_line (int) – number of character to return to line

watex.utils.plotutils.get_color_palette(RGB_color_palette)[source]#

Convert RGB color into matplotlib color palette. In the RGB color system two bits of data are used for each color, red, green, and blue. That means that each color runson a scale from 0 to 255. Black would be 00,00,00, while white would be 255,255,255. Matplotlib has lots of pre-defined colormaps for us . They are all normalized to 255, so they run from 0 to 1. So you need only normalize data, then we can manually select colors from a color map

Parameters:

RGB_color_palette (str) – str value of RGB value

Returns:

rgba, tuple of (R, G, B)

Return type:

tuple

Example:
>>> from watex.utils.plotutils import get_color_palette
>>> get_color_palette (RGB_color_palette ='R128B128')
watex.utils.plotutils.make_mpl_properties(n, prop='color')[source]#

make matplotlib property (‘colors’, ‘marker’, ‘line’) to fit the numer of samples

Parameters:
  • n – int, Number of property that is needed to create. It generates a group of property items.

  • prop – str, default=’color’, name of property to retrieve. Accepts only ‘colors’, ‘marker’ or ‘line’.

Returns:

list of property items with size equals to n.

Example:
>>> from watex.utils.plotutils import make_mpl_properties
>>> make_mpl_properties (10 )
... ['g',
     'gray',
     'y',
     'blue',
     'orange',
     'purple',
     'lime',
     'k',
     'cyan',
     (0.6, 0.6, 0.6)]
>>> make_mpl_properties(100 , prop = 'marker')
... ['o',
     '^',
     'x',
     'D',
      .
      .
      .
     11,
     'None',
     None,
     ' ',
     '']
>>> make_mpl_properties(50 , prop = 'line')
... ['-',
     '-',
     '--',
     '-.',
       .
       .
       .
     'solid',
     'dashed',
     'dashdot',
     'dotted']
watex.utils.plotutils.plot_bar(x, y, wh=0.8, kind='v', fig_size=(8, 6), savefig=None, xlabel=None, ylabel=None, fig_title=None, **bar_kws)[source]#

Make a vertical or horizontal bar plot.

The bars are positioned at x or y with the given alignment. Their dimensions are given by width and height. The horizontal baseline is left (default 0) while the vertical baseline is bottom (default=0)

Many parameters can take either a single value applying to all bars or a sequence of values, one for each bar.

Parameters:
  • x (float or array-like) – The x coordinates of the bars. is ‘x’ for vertical bar plot as kind is set to v``(default) or `y` for horizontal bar plot as `kind` is set to``h. See also align for the alignment of the bars to the coordinates.

  • y (float or array-like) – The height(s) for vertical and width(s) for horizonatal of the bars.

  • wh (float or array-like, default: 0.8) – The width(s) for vertical or height(s) for horizaontal of the bars.

  • kind (str, ['vertical', 'horizontal'], default='vertical') – The kind of bar plot. Can be the horizontal or vertical bar plots.

  • bar_kws (dict,) –

    Additional keywords arguments passed to :

    bar() or barh().

watex.utils.plotutils.plot_clusters(n_clusters, X, y_pred, cluster_centers=None, savefig=None)[source]#

Visualize the cluster that k-means identified in the dataset

Parameters:
  • n_clusters – int, number of cluster to visualize

  • X – NDArray, data containing the features, expect to be a two dimensional data

  • y_pred – array-like, array containing the predicted class labels.

  • cluster_centers – NDArray containg the coordinates of the centroids or the similar points with continous features.

Example:

>>> from watex.exlib.sklearn import KMeans, MinMaxScaler
>>> from watex.utils.plotutils import plot_clusters
>>> from watex.datasets import fetch_data
>>> h= fetch_data('hlogs').frame
>>> # collect two features 'resistivity' and gamma-gamma logging values
>>> h2 = h[['resistivity', 'gamma_gamma']]
>>> km = KMeans (n_clusters =3 , init= 'random' )
>>> # scaled the data with MinMax scaler i.e. between ( 0-1)
>>> h2_scaled = MinMaxScaler().fit_transform(h2)
>>> ykm = km.fit_predict(h2_scaled )
>>> plot_clusters (3 , h2_scaled, ykm , km.cluster_centers_ )
watex.utils.plotutils.plot_confidence(data=None, *, y=None, x=None, ci=0.95, kind='line', b_samples=1000, **sns_kws)[source]#

Plot confidence data

Confidence Interval (CI) is a type of estimate computed from the statistics of the observed data which gives a range of values that’s likely to contain a population parameter with a particular level of confidence. CI as a concept was put forth by Jerzy Neyman in a paper published in 1937. There are various types of the confidence interval, some of the most commonly used ones are: CI for mean, CI for the median, CI for the difference between means, CI for a proportion and CI for the difference in proportions.

Parameters:
  • data (pandas.DataFrame, numpy.ndarray, mapping, or sequence) – Input data structure. Either a long-form collection of vectors that can be assigned to named variables or a wide-form dataset that will be internally reshaped.

  • x (vectors or keys in data) – Variables that specify positions on the x and y axes.

  • y (vectors or keys in data) – Variables that specify positions on the x and y axes.

  • ci (float, default=.95) – Confidence value.

  • kind (str, default='line') – kind of confidence intervval plot.

  • b_samples (int, default=1000) – Number of bootstraps to use for computing the confidence interval.

  • sns_kws (dict,) – Keywords arguments passed to the sns.lineplot or sns.regplot

Returns:

ax – The matplotlib axes containing the plot.

Return type:

matplotlib.axes.Axes

watex.utils.plotutils.plot_confidence_ellipse(x, y)[source]#

Plot a confidence ellipse of a two-dimensional dataset

This function plots the confidence ellipse of the covariance of the given array-like variables x and y. The ellipse is plotted into the given axes-object ax.

The approach that is used to obtain the correct geometry is explained and proved here:

The method avoids the use of an iterative eigen decomposition algorithm and makes use of the fact that a normalized covariance matrix (composed of pearson correlation coefficients and ones) is particularly easy to handle.

watex.utils.plotutils.plot_confusion_matrices(clfs, Xt, yt, annot=True, pkg=None, normalize='true', sample_weight=None, encoder=None, fig_size=(22, 6), savefig=None, subplot_kws=None, **scorer_kws)[source]#

Plot inline multiple model confusion matrices using either the sckitlearn or ‘yellowbrick’

Parameters:
  • clfs (list of classifier estimators) – A scikit-learn estimator that should be a classifier. If the model is not a classifier, an exception is raised. Note that the classifier must be fitted beforehand.

  • Xt (ndarray or DataFrame of shape (M X N)) – A matrix of n instances with m features. Preferably, matrix represents the test data for error evaluation.

  • yt (ndarray of shape (M, ) or Series oF length (M, )) – An array or series of target or class values. Preferably, the array represent the test class labels data for error evaluation.

  • pkg (str, optional , default ='sklearn') – the library to handle the plot. It could be ‘yellowbrick’. The basic confusion matrix is handled by the scikit-learn package.

  • normalize ({'true', 'pred', 'all'}, default=None) – Normalizes confusion matrix over the true (rows), predicted (columns) conditions or all the population. If None, confusion matrix will not be normalized.

  • sample_weight (array-like of shape (n_samples,), default=None) – Sample weights.

  • encoder (dict or LabelEncoder, default: None) – A mapping of classes to human readable labels. Often there is a mismatch between desired class labels and those contained in the target variable passed to fit() or score(). The encoder disambiguates this mismatch ensuring that classes are labeled correctly in the visualization.

  • return_scores (bool, defaut=True,) – Returns a dictionnary of accuracy, precision, recall and AUC scores.

  • annot (bool, default=True) – Annotate the number of samples (right or wrong prediction ) in the plot. Set False to mute the display.

  • fig_size (tuple (width, height), default =(8, 6)) – the matplotlib figure size given as a tuple of width and height

  • savefig (str, default =None ,) – the path to save the figures. Argument is passed to matplotlib.Figure class.

Examples

>>> import matplotlib.pyplot as plt
>>> plt.style.use ('classic')
>>> from watex.datasets import fetch_data
>>> from watex.exlib.sklearn import train_test_split
>>> from watex.models.premodels import p
>>> from watex.utils.plotutils import plot_confusion_matrices
>>> # split the  data . Note that fetch_data output X and y
>>> X, Xt, y, yt  = train_test_split (* fetch_data ('bagoue analysed'), test_size =.25  )
>>> # compose the models
>>> # from RBF, and poly
>>> models =[ p.SVM.rbf.best_estimator_,
         p.LogisticRegression.best_estimator_,
         p.RandomForest.best_estimator_
         ]
>>> models
[SVC(C=2.0, coef0=0, degree=1, gamma=0.125), LogisticRegression(),
 RandomForestClassifier(criterion='entropy', max_depth=16, n_estimators=350)]
>>> # now fit all estimators
>>> fitted_models = [model.fit(X, y) for model in models ]
>>> plot_confusion_matrices(fitted_models , Xt, yt)
watex.utils.plotutils.plot_confusion_matrix(yt, y_pred, view=True, ax=None, annot=True, **kws)[source]#

plot a confusion matrix for a single classifier model.

:param ytndarray or Series of length n

An array or series of true target or class values. Preferably, the array represents the test class labels data for error evaluation.

Parameters:
  • y_pred – ndarray or Series of length n An array or series of the predicted target.

  • view – bool, default=True Option to display the matshow map. Set to False mutes the plot.

  • annot – bool, default=True Annotate the number of samples (right or wrong prediction ) in the plot. Set False to mute the display.

param kws: dict,

Additional keyword arguments passed to the function sckitlearn.metrics.confusion_matrix().

Returns:

mat- confusion matrix bloc matrix

Example:

>>> #Import the required models and fetch a an Ababoost model
>>> # for instance then plot the confusion metric
>>> import matplotlib.pyplot as plt
>>> plt.style.use ('classic')
>>> from watex.datasets import fetch_data
>>> from watex.exlib.sklearn import train_test_split
>>> from watex.models import pModels
>>> from watex.utils.plotutils import plot_confusion_matrix
>>> # split the  data . Note that fetch_data output X and y
>>> X, Xt, y, yt  = train_test_split (* fetch_data ('bagoue analysed'),
                                      test_size =.25  )
>>> # train the model with the best estimator
>>> pmo = pModels (model ='ada' )
>>> pmo.fit(X, y )
>>> print(pmo.estimator_ )
>>> #%%
>>> # Predict the score using under the hood the best estimator
>>> # for adaboost classifier
>>> ypred = pmo.predict(Xt)
>>> # now plot the score
>>> plot_confusion_matrix (yt , ypred )
watex.utils.plotutils.plot_cost_vs_epochs(regs, *, fig_size=(10, 4), marker='o', savefig=None, **kws)[source]#

Plot the cost against the number of epochs for the two different learnings rates

Parameters:
  • regs (Callable, single or list of regression estimators) – Estimator should be already fitted.

  • fig_size (tuple , default is (10, 4)) – the size of figure

  • kws (dict ,) – Additionnal keywords arguments passes to matplotlib.pyplot.plot()

Returns:

ax

Return type:

Matplotlib.pyplot axes objects

Examples

>>> from watex.datasets import load_iris
>>> from watex.base import AdalineGradientDescent
>>> from watex.utils.plotutils import plot_cost_vs_epochs
>>> X, y = load_iris (return_X_y= True )
>>> ada1 = AdalineGradientDescent (n_iter= 10 , eta= .01 ).fit(X, y)
>>> ada2 = AdalineGradientDescent (n_iter=10 , eta =.0001 ).fit(X, y)
>>> plot_cost_vs_epochs (regs = [ada1, ada2] )
watex.utils.plotutils.plot_elbow(X, n_clusters, n_init=10, max_iter=300, random_state=42, fig_size=(10, 4), marker='o', savefig=None, **kwd)[source]#

Plot elbow method to find the optimal number of cluster, k’, for a given data.

Parameters:
  • X ({array-like, sparse matrix} of shape (n_samples, n_features)) – Training instances to cluster. It must be noted that the data will be converted to C ordering, which will cause a memory copy if the given data is not C-contiguous. If a sparse matrix is passed, a copy will be made if it’s not in CSR format.

  • n_clusters (int, default=8) – The number of clusters to form as well as the number of centroids to generate.

  • n_init (int, default=10) – Number of time the k-means algorithm will be run with different centroid seeds. The final results will be the best output of n_init consecutive runs in terms of inertia.

  • max_iter (int, default=300) – Maximum number of iterations of the k-means algorithm for a single run.

  • tol (float, default=1e-4) – Relative tolerance with regards to Frobenius norm of the difference in the cluster centers of two consecutive iterations to declare convergence.

  • verbose (int, default=0) – Verbosity mode.

  • random_state (int, RandomState instance or None, default=42) – Determines random number generation for centroid initialization. Use an int to make the randomness deterministic.

  • savefig (str, default =None ,) – the path to save the figure. Argument is passed to matplotlib.Figure class.

  • marker (str, default='o',) – cluster marker point.

  • kwd (dict) – Addionnal keywords arguments passed to matplotlib.pyplot.plot()

Returns:

ax

Return type:

Matplotlib.pyplot axes objects

Example

>>> from watex.datasets import load_hlogs
>>> from watex.utils.plotutils import plot_elbow
>>> # get the only resistivy and gamma-gama values for example
>>> res_gamma = load_hlogs ().frame[['resistivity', 'gamma_gamma']]
>>> plot_elbow(res_gamma, n_clusters=11)
watex.utils.plotutils.plot_errorbar(ax, x_ar, y_ar, y_err=None, x_err=None, color='k', marker='x', ms=2, ls=':', lw=1, e_capsize=2, e_capthick=0.5, picker=None, **kws)[source]#

convinience function to make an error bar instance

Parameters:
  • ax (matplotlib.axes) – instance axes to put error bar plot on

  • x_array (np.ndarray(nx)) – array of x values to plot

  • y_array (np.ndarray(nx)) – array of y values to plot

  • y_error (np.ndarray(nx)) – array of errors in y-direction to plot

  • x_error (np.ndarray(ns)) – array of error in x-direction to plot

  • color (string or (r, g, b)) – color of marker, line and error bar

  • marker (string) – marker type to plot data as

  • ms (float) – size of marker

  • ls (string) – line style between markers

  • lw (float) – width of line between markers

  • e_capsize (float) – size of error bar cap

  • e_capthick (float) – thickness of error bar cap

  • picker (float) – radius in points to be able to pick a point.

watex.utils.plotutils.plot_learning_curves(models, X, y, *, cv=None, train_sizes=None, baseline_score=0.4, convergence_line=True, fig_size=(20, 6), sns_style=None, savefig=None, set_legend=True, subplot_kws=None, **kws)[source]#

Horizontally visualization of multiple models learning curves.

Determines cross-validated training and test scores for different training set sizes.

Parameters:
  • models (list or estimators) – An estimator instance or not that implements fit and predict methods which will be cloned for each validation.

  • X (array-like of shape (n_samples, n_features)) – Training vector, where n_samples is the number of samples and n_features is the number of features.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Target relative to X for classification or regression; None for unsupervised learning.

  • cv (int, cross-validation generator or an iterable, default=None) –

    Determines the cross-validation splitting strategy.

    Possible inputs for cv are:

    • None, to use the default 5-fold cross validation,

    • int, to specify the number of folds in a (Stratified)KFold,

    • CV splitter,

    • An iterable yielding (train, test) splits as arrays of indices.

    For int/None inputs, if the estimator is a classifier and y is either binary or multiclass, StratifiedKFold is used. In all other cases, KFold is used. These splitters are instantiated with shuffle=False so the splits will be the same across calls.

    Refer User Guide for the various cross-validation strategies that can be used here.

    cv default value if None changed from 3-fold to 4-fold.

    train_sizesarray-like of shape (n_ticks,), default=np.linspace(0.1, 1, 50)

    Relative or absolute numbers of training examples that will be used to generate the learning curve. If the dtype is float, it is regarded as a fraction of the maximum size of the training set (that is determined by the selected validation method), i.e. it has to be within (0, 1]. Otherwise it is interpreted as absolute sizes of the training sets. Note that for classification the number of samples usually have to be big enough to contain at least one sample from each class.

  • baseline_score (floatm default=.4) – base score to start counting in score y-axis (score)

  • convergence_line (bool, default=True) – display the convergence line or not that indicate the level of bias between the training and validation curve.

  • fig_size (tuple (width, height), default =(14, 6)) – the matplotlib figure size given as a tuple of width and height

  • sns_style (str, optional,) – the seaborn style .

  • set_legend (bool, default=True) – display legend in each figure. Note the default location of the legend is ‘best’ from legend()

  • subplot_kws (dict, default is dict(left=0.0625, right = 0.95, wspace = 0.1)) – the subplot keywords arguments passed to matplotlib.subplots_adjust()

  • kws (dict,) – keyword arguments passed to sklearn.model_selection.learning_curve()

Examples

  1. -> plot via a metaestimator already cross-validated.

>>> from watex.models.premodels import p
>>> from watex.datasets import fetch_data
>>> from watex.utils.plotutils import plot_learning_curves
>>> X, y = fetch_data ('bagoue prepared') # yields a sparse matrix
>>> # let collect 04 estimators already cross-validated from SVMs
>>> models = [ p.SVM.linear , p.SVM.rbf , p.SVM.sigmoid , p.SVM.poly ]
>>> plot_learning_curves (models, X, y, cv=4, sns_style = 'darkgrid')
  1. -> plot with multiples models not crossvalidated yet.

>>> from watex.exlib.sklearn import (LogisticRegression,
                                     RandomForestClassifier,
                                     SVC , KNeighborsClassifier
                                     )
>>> models =[LogisticRegression(), RandomForestClassifier(), SVC() ,
             KNeighborsClassifier() ]
>>> plot_learning_curves (models, X, y, cv=4, sns_style = 'darkgrid')
watex.utils.plotutils.plot_logging(X, y=None, zname=None, tname=None, labels=None, impute_nan=True, normalize=False, log10=False, columns_to_skip=None, pattern=None, strategy='mean', posiy=None, fill_value=None, fig_size=(16, 7), fig_dpi=300, colors=None, sns_style=False, savefig=None, draw_spines=False, verbose=0, **kws)[source]#

Plot logging data

Plot expects a collection of logging data. Each logging data composes a column of data collected on the field.Note that can also plot anykind of data related that it contains numerical values. The function does not accept categorical data. If categorical data are given, they should be discarded.

Parameters:
  • X (Dataframe of shape (n_samples, n_features)) – where n_samples is the number of data, expected to be the data collected at different depths and n_features is the number of columns (features) that supposed to be plot. Note that X must include the depth columns. If not given a relative depth should be created according to the number of sample that composes X.

  • y (array-like or series of shape (n_samples,), optional) – Target relative to X for classification or regression; If given, by default the target plot should be located at the last position. However with the argument of posiy , target plot can be toggled to the desired position.

  • zname (str, default='depth' or 'None') – The name of the depth column in X. If the name ‘depth’ is not specified as the main depth columns, an other name in the columns that matches the depth can also be indicated so the function will put aside this columm as depth column for plot purpose. If set to None, zname holds the name depth and assumes that depth exists in X columns.

  • tname (str, optional,) – name of the target. This can rename of the target name if given y as a pandas series or add the name of target if given as an array-like. If not provided, it should use the name of the target series if y is not None.

  • normalize (bool, default = False) – Normalize all the data to be range between (0, 1) except the depth,

  • labels (list or str, optional) – If labels are given, they should fit the size of the number of columns. The given labels should replace the old columns in X and should figue out in the plot. This is usefull to change the columns labels in the dataframe to a new labels that describe the best the plot ; for instance by inluding the units in the new labels. Note that if the labels do not match the size of the old columns in X a warning should be let to the user and none operation will be performed.

  • impute_nan (bool, default=True,) – Replace the NaN values in the dataframe. Note that the default behaviour for replacing NaN is the mean. However if the argument of fill_value is provided,the latter should be used to replace ‘NaN’ in X.

  • log10 (bool, default=False) – Convert values to log10. This can be usefull when using the logarithm data. However, it seems not all the data can be used this operation, for instance, a negative data. In that case, column_to_skip argument is usefull to provide so to skip that columns when converting values to log10.

  • columns_to_skip (list or str, optional,) –

    Columns to skip when performing some operation like ‘log10’. These

    columns with not be affected by the ‘log10’ operations. Note that

    columns_to_skip can also gives as litteral string. In that case, the pattern is need to parse the columns into a list of string.

  • pattern (str, default = '[#&*@!,;s]s*') –

    Regex pattern to parse the columns_to_skip into a list of string where each item is a column name especially when the latter is given as litteral text string. For instance:

    columns_to_skip='depth_top, thickness, sp, gamma_gamma'
    -> ['depth_top', 'thickness', 'sp', 'gamma_gamma']
    

    by using the default pattern. To have full control of columns splitted it is recommended to provided your own pattern to avoid wrong parsing and can lead to an error.

  • strategy (str, default='mean') –

    The imputation strategy.

    • If “mean”, then replace missing values using the mean along each column. Can only be used with numeric data.

    • If “median”, then replace missing values using the median along each column. Can only be used with numeric data.

    • If “most_frequent”, then replace missing using the most frequent value along each column. Can be used with strings or numeric data. If there is more than one such value, only the smallest is returned.

    • If “constant”, then replace missing values with fill_value. Can be used with strings or numeric data.

  • fill_value (str or numerical value, optional) – When strategy == “constant”, fill_value is used to replace all occurrences of missing_values. If left to the default, fill_value will be 0 when imputing numerical data and “missing_value” for strings or object data types. If not given and impute_nan is True, the mean strategy is used instead.

  • posiy (int, optional) – the position to place the target plot y . By default the target plot if given is located at the last position behind the logging plots.

  • colors (list of Matplotlib.colors map, optional) – The colors for plotting each columns of X except the depth. If not given, default colors are auto-generated.

  • draw_spines (bool, tuple (-lim, +lim), default= False,) – Only draw spine between the y-ticks. -lim and +lim are lower and upper bound i.e. a range to draw the spines in y-axis.

  • fig_size (tuple (width, height), default =(8, 6)) – the matplotlib figure size given as a tuple of width and height

  • fig_dpi (float or 'figure', default: rcParams["savefig.dpi"] (default: 'figure')) – The resolution in dots per inch. If ‘figure’, use the figure’s dpi value.

  • savefig (str, default =None ,) – the path to save the figure. Argument is passed to matplotlib.Figure class.

  • sns_style (str, optional,) – the seaborn style.

  • verbose (int, default=0) – Output the number of categorial features dropped in the dataframe.

  • kws (dict,) – Additional keyword arguments passed to matplotlib.axes.plot()

Examples

>>> from watex.datasets import load_hlogs
>>> from watex.utils.plotutils import plot_logging
>>> X0, y = load_hlogs (as_frame =True) # get the frames rather than object
>>> # plot the default logging with Normalize =True
>>> plot_logging (X0, normalize =True)
>>> # Include the target in the plot
>>> plot_logging ( X0,  y = y.kp , posiy = 0,
                  columns_to_skip=['thickness', 'sp'],
                  log10 =True,
                  )
>>> # draw spines and limit plot from (0, 700) m depth
>>> plot_logging (X0 , y= y.kp, draw_spines =(0, 700) )
watex.utils.plotutils.plot_mlxtend_heatmap(df, columns=None, savefig=None, **kws)[source]#

Plot correlation matrix array as a heat map

Parameters:
  • df – dataframe pandas

  • columns – list of features, If given, only the dataframe with that features is considered.

  • kws – additional keyword arguments passed to mlxtend.plotting.heatmap()

Returns:

mlxtend.plotting.heatmap() axes object

Example:

>>> from watex.datasets import load_hlogs
>>> from watex.utils.plotutils import plot_mlxtend_heatmap
>>> h=load_hlogs()
>>> features = ['gamma_gamma', 'sp',
            'natural_gamma', 'resistivity']
>>> plot_mlxtend_heatmap (h.frame , columns =features, cmap ='PuOr')
watex.utils.plotutils.plot_mlxtend_matrix(df, columns=None, fig_size=(10, 8), alpha=0.5, savefig=None)[source]#

Visualize the pair wise correlation between the different features in the dataset in one place.

Parameters:
  • df – dataframe pandas

  • columns – list of features, If given, only the dataframe with that features is considered.

  • fig_size – tuple of int (width, heigh) Size of the displayed figure

  • alpha – figure transparency, default is .5.

Returns:

mlxtend.plotting.scatterplotmatrix() axes object

Example:

>>> from watex.datasets import load_hlogs
>>> from watex.utils.plotutils import plot_mlxtend_matrix
>>> import pandas as pd
>>> import numpy as np
>>> h=load_hlogs()
>>> features = ['gamma_gamma', 'natural_gamma', 'resistivity']
>>> data = pd.DataFrame ( np.log10 (h.frame[features]), columns =features )
>>> plot_mlxtend_matrix (data, columns =features)
watex.utils.plotutils.plot_naive_dendrogram(X, *ybounds, fig_size=(12, 5), savefig=None, **kws)[source]#

Quick plot dendrogram using the ward clustering function from Scipy.

Parameters:
  • X – ndarray of shape (n_samples, n_features) Array of features

  • ybounds – int, integrer values to draw horizontal cluster lines that indicate the number of clusters.

  • fig_size – tuple (width, height), default =(12,5) the matplotlib figure size given as a tuple of width and height

  • kws – dict , Addditional keyword arguments passed to scipy.cluster.hierarchy.dendrogram()

Examples:
>>> from watex.datasets import fetch_data
>>> from watex.utils.plotutils import plot_naive_dendrogram
>>> X, _= fetch_data('Bagoue analysed') # data is already scaled
>>> # get the two features 'power' and  'magnitude'
>>> data = X[['power', 'magnitude']]
>>> plot_naive_dendrogram(data )
>>> # add the horizontal line of the cluster at ybounds = (20 , 20 )
>>> # for a single cluster (cluser 1)
>>> plot_naive_dendrogram(data , 20, 20 )
watex.utils.plotutils.plot_pca_components(components, *, feature_names=None, cmap='viridis', savefig=None, **kws)[source]#

Visualize the coefficient of principal component analysis (PCA) as a heatmap

Parameters:
  • components – Ndarray, shape (n_components, n_features)or PCA object Array of the PCA compoments or object from watex.analysis.dimensionality.nPCA. If the object is given it is not necessary to set the feature_names

  • feature_names – list or str, optional list of the feature names to locate in the map. Feature_names and the number of eigen vectors must be the same length. If PCA object is passed as components arguments, no need to set the feature_names. The name of features is retreived automatically.

  • cmap – str, default=’viridis’ the matplotlib color map for matshow visualization.

  • kws – dict, Additional keywords arguments passed to matplotlib.pyplot.matshow

Examples:

(1)-> with PCA object

>>> from watex.datasets import fetch_data
>>> from watex.utils.plotutils import plot_pca_components
>>> from watex.analysis import nPCA
>>> X, _= fetch_data('bagoue pca')
>>> pca = nPCA (X, n_components=2, return_X =False)# to return object
>>> plot_pca_components (pca)

(2)-> use the components and features individually

>>> components = pca.components_
>>> features = pca.feature_names_in_
>>> plot_pca_components (components, feature_names= features,
                         cmap='jet_r')
watex.utils.plotutils.plot_profiling(erp, /, station=None, cz=None, *, style='classic', fig_size=(10, 4), cz_plot_kws=None, marker_kws=None, savefig=None, **plot_kws)[source]#

Visualizes the resistivity profiling of ERP data.

Function can overlain the selected conductive zone to the ERP if cz is given.

Parameters:
  • erp (array_like 1d) –

    The electrical resistivity profiling array. If dataframe is passed, resistivity column must be included.

    Changed in version 0.2.1: Can henceforth accept dataframe that contains resistivity values.

  • station (str, int, optional) –

    Station is used to visualize the conductive zone in the erp profile.

    This seems useful if cz is not given. When station=’auto’ it automatically detect the best conductive zone assuming the very low resistivity in the profile and plot the conductive zone. To have the expected results, station position or cz must be given or the .

    New in version 0.2.1: Can henceforth pass the station to plot the conductive zone.

  • cz (array_like, optional,) – The selected conductive zone. If None, cz should not be plotted.

  • style (str, default='classic') – Matplotlib plottings style.

  • fig_size (tuple, default= (10, 4)) – Matplotlib figure size.

  • marker_kws (dict, default = {'marker':'o', 'c':'#9EB3DD' }) – The dictionnary to customize marker in the plot

  • cz_plot_kws (dict, default = {'ls':'-','c':'#0A4CEE', 'lw'L2 }) – The dictionnary to customize the conductize zone in the plot.

  • savefig (str, optional) – Save figure name. The default resolution dot-per-inch is 300.

  • plot_kws (dict,) – Additional keyword arguments passed to matplotlib.pyplot.plot() function

Returns:

ax – Return axis

Return type:

Matplotlib.pyplot.Axis

Examples

>>> from watex.datasets import make_erp
>>> from watex.utils.plotutils import plot_profiling
>>> d= make_erp (n_stations =56, seed = 42)
>>> plot_profiling  (d.resistivity)
>>> # read the frame and get the resistivity values
>>> plot_profiling (d.frame, station ='s07' )
<AxesSubplot:xlabel='Stations', ylabel='App.resistivity ($\Omega.m$)'>
watex.utils.plotutils.plot_regularization_path(X, y, c_range=(-4.0, 6.0), fig_size=(8, 5), sns_style=False, savefig=None, **kws)[source]#

Plot the regularisation path from Logit / LogisticRegression

Varying the different regularization strengths and plot the weight coefficient of the different features for different regularization strength.

Note that, it is recommended to standardize the data first.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Training vector, where n_samples is the number of samples and n_features is the number of features. X is expected to be standardized.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Target relative to X for classification or regression; None for unsupervised learning.

  • c_range (list or tuple [start, stop]) – Regularization strength list. It is a range from the strong strong ( start) to lower (stop) regularization. Note that ‘C’ is the inverse of the Logistic Regression regularization parameter \(\lambda\).

  • fig_size (tuple (width, height), default =(8, 6)) – the matplotlib figure size given as a tuple of width and height

  • savefig (str, default =None ,) – the path to save the figures. Argument is passed to matplotlib.Figure class.

  • sns_style (str, optional,) – the seaborn style.

  • kws (dict,) – Additional keywords arguments passed to sklearn.linear_model.LogisticRegression

Examples

>>> from watex.utils.plotutils import plot_regularization_path
>>> from watex.datasets import fetch_data
>>> X, y = fetch_data ('bagoue analysed' ) # data aleardy standardized
>>> plot_regularization_path (X, y )
watex.utils.plotutils.plot_rf_feature_importances(clf, X=None, y=None, fig_size=(8, 4), savefig=None, n_estimators=500, verbose=0, sns_style=None, **kws)[source]#

Plot features importance with RandomForest.

Parameters:
  • clf (estimator object) – The base estimator from which the transformer is built. This can be both a fitted (if prefit is set to True) or a non-fitted estimator. The estimator should have a feature_importances_ or coef_ attribute after fitting. Otherwise, the importance_getter parameter should be used.

  • X (array-like of shape (n_samples, n_features)) – Training vector, where n_samples is the number of samples and n_features is the number of features.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Target relative to X for classification or regression; None for unsupervised learning.

  • n_estimators (int, default=500) – The number of trees in the forest.

  • fig_size (tuple (width, height), default =(8, 6)) – the matplotlib figure size given as a tuple of width and height

  • savefig (str, default =None ,) – the path to save the figures. Argument is passed to matplotlib.Figure class.

  • sns_style (str, optional,) – the seaborn style.

  • verbose (int, default=0) – print the feature labels with the rate of their importances.

  • kws (dict,) – Additional keyyword arguments passed to sklearn.ensemble.RandomForestClassifier

Examples

>>> from watex.datasets import fetch_data
>>> from watex.exlib.sklearn import RandomForestClassifier
>>> from watex.utils.plotutils import plot_rf_feature_importances
>>> X, y = fetch_data ('bagoue analysed' )
>>> plot_rf_feature_importances (
    RandomForestClassifier(), X=X, y=y , sns_style=True)
watex.utils.plotutils.plot_sbs_feature_selection(sbs_estimator, /, X=None, y=None, fig_size=(8, 5), sns_style=False, savefig=None, verbose=0, **sbs_kws)[source]#

plot Sequential Backward Selection (SBS) for feature selection.

SBS collects the scores of the best feature subset at each stage.

Parameters:
  • sbs_estimator (SequentialBackwardSelection estimator object) – The Sequential Backward Selection estimator can either be fitted or not. If not fitted. Please provide the training X and y, otherwise an error will occurs.

  • X (array-like of shape (n_samples, n_features)) – Training vector, where n_samples is the number of samples and n_features is the number of features.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Target relative to X for classification or regression; None for unsupervised learning.

  • n_estimators (int, default=500) – The number of trees in the forest.

  • fig_size (tuple (width, height), default =(8, 6)) – the matplotlib figure size given as a tuple of width and height

  • savefig (str, default =None ,) – the path to save the figures. Argument is passed to matplotlib.Figure class.

  • sns_style (str, optional,) – the seaborn style.

  • verbose (int, default=0) – print the feature labels with the rate of their importances.

  • sbs_kws (dict,) – Additional keyyword arguments passed to SequentialBackwardSelection

Examples

(1)-> Plot fitted SBS in action >>> from watex.exlib.sklearn import KNeighborsClassifier , train_test_split >>> from watex.datasets import fetch_data >>> from watex.base import SequentialBackwardSelection >>> from watex.utils.plotutils import plot_sbs_feature_selection >>> X, y = fetch_data(‘bagoue analysed’) # data already standardized >>> Xtrain, Xt, ytrain, yt = train_test_split(X, y) >>> knn = KNeighborsClassifier(n_neighbors=5) >>> sbs= SequentialBackwardSelection (knn) >>> sbs.fit(Xtrain, ytrain ) >>> plot_sbs_feature_selection(sbs, sns_style= True)

(2)-> Plot estimator with no prefit SBS. >>> plot_sbs_feature_selection(knn, Xtrain, ytrain) # yield the same result

watex.utils.plotutils.plot_silhouette(X, labels, metric='euclidean', savefig=None, **kwds)[source]#

Plot quantifying the quality of clustering silhouette

Parameters:
  • X (array-like of shape (n_samples_a, n_samples_a) if metric == ) – “precomputed” or (n_samples_a, n_features) otherwise An array of pairwise distances between samples, or a feature array.

  • labels (array-like of shape (n_samples,)) – Label values for each sample.

  • metric (str or callable, default='euclidean') – The metric to use when calculating distance between instances in a feature array. If metric is a string, it must be one of the options allowed by sklearn.metrics.pairwise.pairwise_distances(). If X is the distance array itself, use “precomputed” as the metric. Precomputed distance matrices must have 0 along the diagonal.

  • savefig (str, default =None ,) – the path to save the figure. Argument is passed to matplotlib.Figure class.

  • **kwds (optional keyword parameters) – Any further parameters are passed directly to the distance function. If using a scipy.spatial.distance metric, the parameters are still metric dependent. See the scipy docs for usage examples.

See also

watex.view.mlplot.plotSilhouette

Gives consistency plot as the use of prefit parameter which checks whether`labels` are expected to be passed into the function directly or not.

Examples

>>> import numpy as np
>>> from watex.exlib.sklearn import KMeans
>>> from watex.datasets import load_iris
>>> from watex.utils.plotutils import plot_silhouette
>>> d= load_iris ()
>>> X= d.data [:, 0][:, np.newaxis] # take the first axis
>>> km= KMeans (n_clusters =3 , init='k-means++', n_init =10 ,
                max_iter = 300 ,
                tol=1e-4,
                random_state =0
                )
>>> y_km = km.fit_predict(X)
>>> plot_silhouette (X, y_km)
watex.utils.plotutils.plot_skew(edi_obj, method='Bahr', mode=None, threshold_line=None, fig_size=(7, 5), savefig=None, view=None, style=None, **kws)[source]#

Plot phase sensitive skew visualization.

Phase Sensitivity Skew (\(\eta\)) is a dimensionality tool that represents a measure of the skew of the phases of the impedance tensor. The parameter is thus unaffected by the distortion effect, unlike the Swift-skew and ellipticity dimensionality tools [1].

Values of \(\eta\) > 0.3 are considered to represent 3D data. Phase-sensitive skews less than 0.1 indicate 1D, 2D or distorted 2D (3-D /2-D) cases. Values of \(\eta\) between 0.1 and 0.3 indicates modified 3D/2D structures [2] according to Bahr’ methods. However, values :math:eta >=0.2` using the Swift methods, the smaller the value \(\eta\) ( close to \(0.\)), the closer the structure to 2D structure and vice versa.However, it is generally considered that an electrical structure of \(\eta < 0.4\) can be treated as a 2D medium. Here as the threshold_line for eta() using the Swift method should be set as 0.4.

New in version 0.1.5.

Parameters:
  • edi_obj (str, watex.edi.Edi) – Full path to edifiles or Edi object.

  • method (str, default='Bahr':) – Kind of correction. Can be swift for the remove distorsion proposed by Swift in 1967 [3]. The value close to 0. assume the 1D and 2D structures, and 3D otherwise. Conversly to bahr for the remove distorsion proposed by Bahr in 1991 [2]. The latter threshold is set to 0.3. Above this value the structures is 3D.

  • threshold_line (float, optional) –

    Visualize th threshold line. Can be [‘bahr’, ‘swift’, ‘both’]:

    • Note that when method is set to swift, the value close to close to \(0.\) assume the 1D and 2D structures, and 3D otherwise.

    • when method is set to Bahr, \(\mu > 0.3`\) is 3D structures, between \([0.1 - 0.3]\) assumes modified 3D/2D structures whereas \(<0.1\) 1D, 2D or distorted 2D.

  • mode (str, optional) – X-axis coordinates for visualisation. plot either 'frequency' or 'periods'. The default is 'frequency'

  • view (str, default='skew') – phase sensistive visualization. Can be rotational invariant invariant. Note that setting to mu or invariant does not change any interpretation since the distortion of Z are all rotational invariant whether using the Bahr or swift methods.

  • fig_size (tuple, default= (10, 4)) – Matplotlib figure size.

  • savefig (str, optional) – Save figure name. The default resolution dot-per-inch is 300.

  • style (str, default='classic') – Matplotlib plottings style.

  • kws (dict,) – Matplotlib Axes scatterplot additional keywords arguments.

Returns:

ax – Return axis

Return type:

Matplotlib.pyplot.Axis

See also

watex.methods.em.Processing.skew

Skew equation formulations.

watex.view.TPlot.plotSkew

Give a consistent plot where user can customize the plot using the plot parameter of watex.property.BasePlot class.

References

[1]

Bahr, K. (1988) Interpretation of the magnetotelluric impedance tensor: regional induction 395 and local telluric distortion. J. Geophys. Res., 62, 119–127.

[2] (1,2)

Bahr, K. (1991) Geological noise in magnetotelluric data: a classification of distortion types. 397 Phys. Earth Planet. Inter., 66, 24–38.

[3]

Bahr, K., 1991. Geological noise in magnetotelluric data: a classification of distortion types. Physics of the Earth and Planetary Interiors 66 (1–2), 24–38.

Examples

>>> import watex as wx
>>> from watex.utils.plotutils import plot_skew
>>> edi_sk = wx.fetch_data ("edis", return_data =True , samples = 20 )
>>> plot_skew (edi_sk)
>>> plot_skew (edi_sk, threshold_line= True)
watex.utils.plotutils.plot_strike(list_of_edis, /, kind=2, period_tolerance=0.05, text_pad=1.65, rot_z=0.0, **kws)[source]#

Plot the strike estimated from the invariants and phase tensor. in a rose diagram of xy plot.

Parameters:
  • list_of_edis (list,) –

    full paths to .edi files to plot or list of EDI-files.

    Changed in version 0.2.0: No need to provide a list of term:EDI files. Henceforth list_of_edis accepts the EDI path-like object of single EDI file then asserts the validity of the EDI files afterward.

  • kind (int, default=2) –

    Can be [ 1 | 2 ] where:

    • 1 to plot individual decades in one plot

    • 2 to plot all period ranges into one polar diagram for each strike angle estimation

    One could try also plot_type = 1 to plot by decade

  • fig_num (int, default=1,) – figure number to be plotted. Default is 1

  • font_size (float, default=10,) – Figure size

  • rot_z (float, default=0.,) – angle of rotation clockwise positive.

  • period_tolerance (float, default=.05) – Tolerance level to match periods from different edi files. Default is 0.05

  • text_pad (float, default=1.65) –

    padding of the angle label at the bottom of each

    polar diagram. Default is 1.65

  • plot_range (str, tuple) –

    The period range to estimate the strike angle. It can be [ ‘data’ | (period_min,period_max) ]. Options are:

    • ’data’ for estimating the strike for all periods in the data.

    • (pmin,pmax) for period min and period max, input as (log10(pmin),log10(pmax))

  • plot_tipper ([ True | False ]) –

    • True to plot the tipper strike

    • False to not plot tipper strike

  • pt_error_floor (int, optional) – Maximum error in degrees that is allowed to estimate strike. Default is None allowing all estimates to be used.

  • fold ([ True | False ]) –

    • True to plot only from 0 to 180

    • False to plot from 0 to 360

  • plot_orthogonal ([ True | False]) –

    • True to plot the orthogonal strike directions

    • False to not

  • color ([ True | False ]) –

    • True to plot shade colors

    • False to plot all in one color

  • color_inv (str,) – color of invariants plots

  • color_pt (str,) – color of phase tensor plots

  • color_tip (str) – color of tipper plots

  • ring_spacing (float, optional) – spacing of rings in polar plots

  • ring_limits (tuple of int,) – plot limits (min count, max count) set each plot have these limits

  • plot_orientation (str, [ 'h' | 'v' ]) – horizontal or vertical plots

watex.utils.plotutils.plot_text(x, y, text=None, data=None, coerce=False, basename='S', fig_size=(7, 7), show_line=False, step=None, xlabel='', ylabel='', color=None, show_leg=False, linelabel='', markerlabel='', **text_kws)[source]#

Plot text(s) indicating each position in the line.

Parameters:
  • x (str, float, Array-like) – The position to place the text. By default, this is in data coordinates. The coordinate system can be changed using the transform parameter.

  • y (str, float, Array-like) – The position to place the text. By default, this is in data coordinates. The coordinate system can be changed using the transform parameter.

  • text (str,) – The text

  • data (pd.DataFrame,) – Data containing x and y names. Need to be supplied when x and y are given as string names.

  • coerce (bool, default=False) – Force the plot despite the given textes do not match the number of positions x and y. If False, number of positions must be consistent with x and y, otherwise error raises.

  • basename (str, default='S') – the text to prefix the position when the text is not given.

  • fig_size (tuple, default=(7, 7)) – Matplotlib figure size.

  • show_line (bool, default=False) – Display the line from x, y.

  • step (int,Optional) – The number of intermediate positions to skip in the plotting text.

  • xlabel (str, Optional,) – The labels of x and y.

  • ylabel (str, Optional,) – The labels of x and y.

  • color (str, Optional) – Line color if show_line is set to True.

  • show_leg (bool, default=False) – Display the legend of line and marker labels.

  • linelabel (str, Optional) – The labels of the line and marker.

  • markerlabel (str, Optional) – The labels of the line and marker.

  • text_kws (dict,) – Keyword arguments passed to matplotlib.axes.Axes.text().

Examples

>>> import watex as wx
>>> data =wx.make_erp (as_frame =True, n_stations= 7 )
>>> x , y =[ 0, 1, 3 ], [2, 3, 6]
>>> texto = ['AMT-E1147', 'AMT-E1148',  'AMT-E180']
>>> plot_text (x, y , text = texto)# no need to set  coerce, same length
>>> data =wx.make_erp (as_frame =True, n_stations= 20 )
>>> x , y = data.easting, data.northing
>>> text1 = ['AMT-E1147', 'AMT-E1148',  'AMT-E180']
>>> plot_text (x, y , coerce =True , text = text1 , show_leg= True,
               show_line=True, linelabel='E1-line', markerlabel= 'Site',
           basename ='AMT-E0'
           )
watex.utils.plotutils.plot_yb_confusion_matrix(clf, Xt, yt, labels=None, encoder=None, savefig=None, fig_size=(6, 6), **kws)[source]#

Confusion matrix plot using the ‘yellowbrick’ package.

Creates a heatmap visualization of the sklearn.metrics.confusion_matrix(). A confusion matrix shows each combination of the true and predicted classes for a test data set.

The default color map uses a yellow/orange/red color scale. The user can choose between displaying values as the percent of true (cell value divided by sum of row) or as direct counts. If percent of true mode is selected, 100% accurate predictions are highlighted in green.

Requires a classification model.

Be sure ‘yellowbrick’ is installed before using the function, otherwise an ImportError will raise.

Parameters:
  • clf (classifier estimator) – A scikit-learn estimator that should be a classifier. If the model is not a classifier, an exception is raised. If the internal model is not fitted, it is fit when the visualizer is fitted, unless otherwise specified by is_fitted.

  • Xt (ndarray or DataFrame of shape n x m) – A matrix of n instances with m features. Preferably, matrix represents the test data for error evaluation.

  • yt (ndarray or Series of length n) – An array or series of target or class values. Preferably, the array represent the test class labels data for error evaluation.

  • ax (matplotlib Axes, default: None) – The axes to plot the figure on. If not specified the current axes will be used (or generated if required).

  • sample_weight (array-like of shape = [n_samples], optional) – Passed to confusion_matrix to weight the samples.

  • encoder (dict or LabelEncoder, default: None) – A mapping of classes to human readable labels. Often there is a mismatch between desired class labels and those contained in the target variable passed to fit() or score(). The encoder disambiguates this mismatch ensuring that classes are labeled correctly in the visualization.

  • labels (list of str, default: None) – The class labels to use for the legend ordered by the index of the sorted classes discovered in the fit() method. Specifying classes in this manner is used to change the class names to a more specific format or to label encoded integer classes. Some visualizers may also use this field to filter the visualization for specific classes. For more advanced usage specify an encoder rather than class labels.

  • fig_size (tuple (width, height), default =(8, 6)) – the matplotlib figure size given as a tuple of width and height

  • savefig (str, default =None ,) – the path to save the figures. Argument is passed to matplotlib.Figure class.

Returns:

cmo – return a yellowbrick confusion matrix object instance.

Return type:

yellowbrick.classifier.confusion_matrix.ConfusionMatrix

Examples

>>> #Import the required models and fetch a an extreme gradient boosting
>>> # for instance then plot the confusion metric
>>> import matplotlib.pyplot as plt
>>> plt.style.use ('classic')
>>> from watex.datasets import fetch_data
>>> from watex.exlib.sklearn import train_test_split
>>> from watex.models import pModels
>>> from watex.utils.plotutils import plot_yb_confusion_matrix
>>> # split the  data . Note that fetch_data output X and y
>>> X, Xt, y, yt  = train_test_split (* fetch_data ('bagoue analysed'),
                                      test_size =.25  )
>>> # train the model with the best estimator
>>> pmo = pModels (model ='xgboost' )
>>> pmo.fit(X, y )
>>> print(pmo.estimator_ ) # pmo.XGB.best_estimator_
>>> #%%
>>> # Predict the score using under the hood the best estimator
>>> # for adaboost classifier
>>> ypred = pmo.predict(Xt)
>>> # now plot the score
>>> plot_yb_confusion_matrix (pmo.XGB.best_estimator_, Xt, yt  )
watex.utils.plotutils.plotvec1(u, z, v)[source]#

Plot tips function with three vectors.

Parameters:
  • u (array like) – vector u - a vector

  • z (array_like) – vector z

  • v (array_like) – vector v

return: plot

watex.utils.plotutils.plotvec2(a, b)[source]#

Plot tips function with two vectors Just use to get the orthogonality of two vector for other purposes

Parameters:
  • a (array like - a vector) – vector u

  • b (array_like) – vector z

  • Write your code below and press Shift+Enter to execute

Example:
>>> import numpy as np
>>> from watex.utils.plotutils import plotvec2
>>> a=np.array([1,0])
>>> b=np.array([0,1])
>>> Plotvec2(a,b)
>>> print('the product a to b is =', np.dot(a,b))
watex.utils.plotutils.resetting_colorbar_bound(cbmax, cbmin, number_of_ticks=5, logscale=False)[source]#

Function to reset colorbar ticks more easy to read

Parameters:
  • cbmax (float) – value maximum of colorbar

  • cbmin (float minimum data value) – minimum data value

  • number_of_ticks (int) – number of ticks should be located on the color bar . Default is 5.

  • logscale (bool) – set to True if your data are lograith data .

Returns:

array of color bar ticks value.

Return type:

array_like

watex.utils.plotutils.resetting_ticks(get_xyticks, number_of_ticks=None)[source]#

resetting xyticks modulo , 100

Parameters:
  • get_xyticks (list) – xyticks list , use to ax.get_x|yticks()

  • number_of_ticks (int) – maybe the number of ticks on x or y axis

Returns:

a new_list or ndarray

Return type:

list or array_like

watex.utils.plotutils.savefigure(fig, figname=None, ext='.png', **skws)[source]#

save figure from the given figure name

Parameters:
  • fig – Matplotlib figure object

  • figname – name of figure to output

  • ext – str - extension of the figure

  • skws – Matplotlib savefigure keywards additional keywords arguments

Returns:

Matplotlib savefigure objects.