paramonte.vis._BasePlot
¶
Module Contents¶
Classes¶
|
This is the class for generating instances of |
-
paramonte.vis._BasePlot.
newline
¶
-
class
paramonte.vis._BasePlot.
BasePlot
(plotType, dataFrame=None, methodName='ParaMonte', reportEnabled=True, resetPlot=None)[source]¶ This is the class for generating instances of basic plots with minimally one (X)-axis. It serves as the superclass for a wide variety of other multi-axes ParaMonte plots.
Parameters
plotType
A string indicating the name of the plot that is to be constructed.
dataFrame (optional)
A pandas dataFrame whose data will be plotted.
methodName (optional)
The name of the ParaMonte sample requesting the BasePlot.
reportEnabled (optional)
A boolean whose value indicates whether guidelines should be printed in the standard output.
resetPlot (optional)
A function that resets the properties of the plot as desired from outside. If provided, a pointer to this function will be saved for future internal usage.
Attributes
_dfref
A weak reference to the input dataFrame whose data is used to generate plots.
rows
A numeric vector that determines the rows of dataFrame to be visualized. It can be either:
a
range(start,stop,step)
, or,a list of row indices in
dataFrame.index
.
Examples:
rows = range(17,7,-2)
rows = [i for i in range(7,17)]
If not provided, the default includes all rows of the dataframe.
set
A structure with two attributes:
enabled
A boolean indicating whether a call to the
set()
function of the seaborn library should be made or not.kws
A structure whose components are directly passed as keyword arguments to the
set()
function.Example usage:
set.kws.style = "darkgrid"
NOTE
If a desired property is missing among the
kws
attributes, simply add the field and its value to the component.axes (available only in 1D and 2D plots)
A structure with one attribute:
kws
A structure whose components are directly passed as keyword arguments to the
gca()
function of the matplotlib library.Example usage:
axes.kws.facecolor = "w"
NOTE
If a desired property is missing among the
kws
attributes, simply add the field and its value to the component.axes3d (available only in 3D plots)
A structure with one attribute:
kws
A structure whose components are directly passed as keyword arguments to the
Axes3D()
function of the matplotlib library.Example usage:
axes3d.kws.facecolor = "w"
NOTE
If a desired property is missing among the
kws
attributes, simply add the field and its value to the component.figure
A structure with two attributes:
enabled
A boolean indicating whether a call to the
figure()
function of the matplotlib library should be made or not. If a call is made, a new figure will be generated. Otherwise, the current active figure will be used.kws
A structure whose components are directly passed as keyword arguments to the
figure()
function of the matplotlib library.Example usage:
figure.kws.facecolor = "w"
NOTE
If a desired property is missing among the
kws
attributes, simply add the field and its value to the component.legend (may not exist for some types of plots)
A structure with two attributes:
enabled
A boolean indicating whether a call to the
legend()
function of the matplotlib library should be made or not. If a call is made, a new figure will be generated. Otherwise, the current active figure will be used.kws
A structure whose components are directly passed as keyword arguments to the
legend()
function of the matplotlib library.Example usage:
legend.kws.labels = ["Variable1", "Variable2"]
NOTE
If a desired property is missing among the
kws
attributes, simply add the field and its value to the component.A legend will be added to a plot only if no color-mappings are requested in the plot.
currentFig
A structure whose attributes are the outputs of various plotting tools used to make the current figure. These include the handle to the current figure, the handle to the current axes in the plot, the handle to the colorbar (if any exists), and other Python plotting tools used to make to generate the figure.
Returns
An object of
BasePlot
class.-
reset
(self, resetType='soft', **kwargs)[source]¶ Reset the properties of the plot to the original default settings. Use this method when you change many attributes of the plot and you want to clean up and go back to the default settings.
Parameters
resetType (optional)
An optional string with possible value of
"hard"
. If provided, the plot object will be regenerated from scratch. This includes reading the original data frame again and resetting everything. If not provided, then only the plot settings will be reset without reseting the dataFrame.Returns
None
Example
1 2 3
reset() # reset the plot to the default settings reset("soft") # reset the plot to the default settings reset("hard") # regenerate the plot from scratch
-
savefig
(self, reself=False, **savefig_kws)[source]¶ Export the current figure to external file.
Parameters
reself
A logical variable. If
True
, the path to the output generated file will be returned. The default value isFalse
.**savefig_kws (optional)
The set of input arguments to the
savefig()
function of the matplotlib library, including thefname
. If the file name is not provided, a unique random filename will be generated and used to save the figure to an output file.Example:
savefig(fname = "gridplot.png")
Returns
None
Example
savefig() # use a unique random filename to output the plot. savefig(fname = "thisPlot.png") savefig(pad_inches = 0.0, bbox_inches = "tight")
-
getLinSpace
(self, skip=None, lowerLim: tp.Optional[np.int32] = 1, upperLim: tp.Optional[np.int32] = None)[source]¶ Generate linearly-spaced unique integer numbers between the input lowerLim and upperLim. These numbers can be used as the row indices in the plots.
Parameters
skip (optional)
The linear spacing between the generated points. If
skip
is specified as input, any input value fornpoint
will be ignored. The default value isNone
.lowerLim (optional)
The natural (non-logarithmic) lower limit of the generated linearly-spaced integer numbers. If not provided, the default value is
1
.upperLim (optional)
The natural (non-logarithmic) upper limit of the generated linearly-spaced integer numbers. If not provided, the default value is the maximum of the number of the rows of the input dataframe to the
BasePlot
constructor.Returns
A set of unique linearly-spaced integer numbers.
Example
rows = getLinSpace(3, 1, 10000)
-
getLogLinSpace
(self, base: tp.Optional[np.float64] = 1.2, logskip: tp.Optional[np.int32] = 0.2, lowerLim: tp.Optional[np.int32] = 1, upperLim: tp.Optional[np.int32] = None)[source]¶ Generate logarithmically-uniformly-spaced unique integer numbers between the input lowerLim and upperLim. These numbers are to be used as the row indices in the plots.
Parameters
base (optional)
The base of the logarithm used for generating the logarithmically-uniform range of integers. The default value is
1.2
.logskip (optional)
The minimum logarithmic space jump between the generated log-linearly-spaced integer numbers. The default value is
0.2
.lowerLim (optional)
The natural (non-logarithmic) lower limit of the generated log-linearly-spaced integer numbers. If not provided, the default value is
1
.upperLim (optional)
The natural (non-logarithmic) upper limit of the generated log-linearly-spaced integer numbers. If not provided, the default value is the maximum of the number of the rows of the input dataframe to the BasePlot constructor.
Returns
A set of unique log-linearly-spaced integer numbers.
Example
rows = getLogLinSpace(1.01, 1, 1, 10000)
-
_constructBasePlot
(self)[source]¶ Generate Figure and Axes instances if needed and return nothing.
Parameters
None
Returns
None
-
_finalizeBasePlot
(self)[source]¶ Set the base Figure properties, such as legends, …
Parameters
None
Returns
None