:mod:`paramonte.vis.DensityPlot` ================================ .. py:module:: paramonte.vis.DensityPlot Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: paramonte.vis.DensityPlot.DensityPlot .. data:: Struct .. data:: newline .. py:class:: DensityPlot(plotType, dataFrame=None, methodName='ParaMonte', reportEnabled=True, resetPlot=None) Bases: :class:`paramonte.vis._BasePlot.BasePlot` This is the DensityPlot class for generating instances of histogram and contour figures in two and three dimensions based on a wide range of plotting tools from the matplotlib, seaborn, and other Python libraries. Normally, the public users are not supposed to use this class directly, although they can for the purposes other than plotting the ParaMonte simulation files. **Parameters** plotType A string indicating the name of the plot 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** xcolumns An attribute that determines the columns of dataFrame to be visualized as the X-axis. It can have three forms: 1. A list of column indices in dataFrame. 2. A list of column names in dataFrame.columns. 3. A ``range(start,stop,step)`` of column indices. Examples: 1. ``xcolumns = [0,1,4,3]`` 2. ``xcolumns = ["SampleLogFunc","SampleVariable1"]`` 3. ``xcolumns = range(17,7,-2)`` The default behavior includes all columns of the dataFrame. ycolumns (only in kdeplot2, contour, contourf, contour3 plots) An attribute that determines the columns of dataFrame to be visualized as the Y-axis. It can have three forms: 1. A list of column indices in dataFrame. 2. A list of column names in dataFrame.columns. 3. A ``range(start,stop,step)`` of column indices. Examples: 1. ``ycolumns = [0,1,4,3]`` 2. ``ycolumns = ["SampleLogFunc","SampleVariable1"]`` 3. ``ycolumns = range(17,7,-2)`` The default behavior includes all columns of the dataFrame. rows An attribute that determines the rows of dataFrame to be visualized. It can be either: 1. A ``range(start,stop,step)``, or, 2. A list of row indices in dataFrame.index. Examples: 1. ``rows = range(17,7,-2)`` 2. ``rows = [i for i in range(7,17)]`` The default behavior includes all rows of the dataFrame. histplot (available only in histplot objects) A structure with two attributes: enabled A boolean indicating whether a call to the ``histplot()`` function of the seaborn library should be made or not. kws A structure whose components are directly passed as keyword arguments to the ``histplot()`` function. Example usage: .. code-block:: python :linenos: histplot.kws.stat = "count" **NOTE** If a desired property is missing among the ``kws`` attributes, simply add the field and its value to the component. kdeplot (available only in ``kdeplot1`` and ``kdeplot2`` objects) A structure with two attributes: enabled A boolean indicating whether a call to the ``kdeplot()`` function of the seaborn library should be made or not. kws A structure whose components are directly passed as keyword arguments to the ``kdeplot()`` function. Example usage: .. code-block:: python :linenos: kdeplot.kws.cbar = True kdeplot.kws.shade = False **NOTE** If a desired property is missing among the ``kws`` attributes, simply add the field and its value to the component. contour (available only in ``contour`` and ``contour3`` objects) A structure with two attributes: enabled A boolean indicating whether a call to the ``contour()`` function of the seaborn library should be made or not. kws A structure whose components are directly passed as keyword arguments to the ``contour()`` function. Example usage: .. code-block:: python :linenos: contour.kws.cmap = "winter" contour.kws.levels = 50 **NOTE** If a desired property is missing among the ``kws`` attributes, simply add the field and its value to the component. contourf (available only in ``contourf`` objects) A structure with two attributes: enabled A boolean indicating whether a call to the ``contourf()`` function of the seaborn library should be made or not. kws A structure whose components are directly passed as keyword arguments to the ``contourf()`` function. Example usage: .. code-block:: python :linenos: contour.kws.cmap = "winter" contour.kws.levels = 50 **NOTE** If a desired property is missing among the ``kws`` attributes, simply add the field and its value to the component. gridSize (available in ``contour``, ``contourf``, ``contour3`` objects) An integer indicating the grid resolution for discretization of the data during the kernel density estimation. It must be a power of two, otherwise it will be changed to the next power of two at the time of using it. The default value is 512. Example usage: .. code-block:: python gridSize = 512 limits (available in ``contour``, ``contourf``, ``contour3`` objects) Data ``limits`` used in the kernel density estimation specified as a tuple of tuples ``((xmin, xmax), (ymin, ymax))``. If any of the values are ``None``, they will be inferred from the data. Each tuple, or even both of them, may also be replaced by a single value denoting the upper bound of a range centered at zero. The default is ``None``. Example usage: .. code-block:: python limits = ( (-10, 10),(-5,5) ) noiseDensity (available in ``contour``, ``contourf``, ``contour3``) A float indicating the threshold below which the kernel density estimate is considered to be noise and is rounded to zero. The higher this value is, the less noise will be visible. Example usage: .. code-block:: python noiseDensity = 1.e-5 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: .. code-block:: python 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: .. code-block:: python 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: .. code-block:: python 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. Example usage: .. code-block:: python 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. colorbar (exists only for plots that require colorbar) A structure with two attributes: enabled A boolean indicating whether a call to the ``colorbar()`` 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 ``colorbar()`` function of the matplotlib library. **NOTE** If a desired property is missing among the ``kws`` attributes, simply add the field and its value to the component. A colorbar will be added to a plot only if a color-mappings is requested in the plot. 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. Example usage: .. code-block:: python 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. target (available only in 1D and 2D plot objects) A callable object of the ParaMonte library's ``Target`` class which can be used to add target point or lines to the current active plot. **Returns** An object of class ``DensityPlot``. --------------------------------------------------------------------------- .. method:: _reset(self) .. method:: __call__(self, reself: tp.Optional[bool] = False, **kwargs) Call the ``make()`` method of the current instance of the class. **Parameters** Any arguments that can be passed to the ``make()`` method of the plot object. **Returns** Any return value from the ``make()`` method of the plot object. .. method:: make(self, reself: tp.Optional[bool] = False, **kwargs) Generate a plot from the selected columns of the object's dataFrame. **Parameters** reself A logical variable. If ``True``, an instance of the object will be returned to the calling routine upon exit. The default value is ``False``. **Returns** The object self if ``reself = True`` otherwise, ``None``. However, this method causes side-effects by manipulating the existing attributes of the object. **NOTE** **This method causes side-effects by manipulating the existing attributes of the object.** .. method:: _getDocString(self) .. method:: helpme(self, topic=None) Print the documentation for the input string topic. If the topic does not exist, the documentation for the object will be printed. **Parameters** topic (optional) A string containing the name of the object for which help is needed. **Returns** None **Example** .. code-block:: python :linenos: helpme() helpme("make") helpme("helpme") helpme("getLogLinSpace")