validate_plotting_kwargs#
- scikitplot.api._utils.validate_plotting_kwargs(*args, **kwargs)[source]#
Validate the provided axes and figure or create new ones if needed.
This function checks if valid axes and figure objects are provided. If not, it creates new ones based on the specified parameters.
Added in version 0.3.9.
- Parameters:
- axmatplotlib.axes.Axes, optional, default=None
The axis to plot the figure on. If None is passed in the current axes will be used (or generated if required).
- figmatplotlib.pyplot.figure, optional, default: None
The figure to plot the Visualizer on. If None is passed in the current plot will be used (or generated if required).
- figsizetuple, optional, default=None
Width, height in inches. Tuple denoting figure size of the plot e.g. (12, 5)
- nrowsint, optional, default=1
Number of rows in the subplot grid.
- ncolsint, optional, default=1
Number of columns in the subplot grid.
- plot_stylestr, optional, default=None
Check available styles with “plt.style.available”. Examples include: [‘ggplot’, ‘seaborn’, ‘bmh’, ‘classic’, ‘dark_background’, ‘fivethirtyeight’, ‘grayscale’, ‘seaborn-bright’, ‘seaborn-colorblind’, ‘seaborn-dark’, ‘seaborn-dark-palette’, ‘tableau-colorblind10’, ‘fast’].
Added in version 0.4.0.
- Returns:
- figmatplotlib.figure.Figure
The figure to be used for plotting.
- axmatplotlib.axes.Axes or list of matplotlib.axes.Axes
The axes to be used for plotting. Returns a single Axes object if only one subplot is created, or a list of Axes objects if multiple subplots are created.
- Parameters:
Notes
The subplot position can be described by either:
Three integers (nrows, ncols, index)
The subplot will take the index position on a grid with nrows rows and ncols columns. index starts at 1 in the upper left corner and increases to the right.
Examples
Create a new figure and axes:
>>> fig, ax = validate_plotting_kwargs()
Use an existing axes:
>>> fig, ax = plt.subplots() >>> fig, ax = validate_plotting_kwargs(ax=ax)