Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions docs/api/plot.rst
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
========
Plotters
Plotting
========

Create figures and subplots of non-linear search specific visualization of every search algorithm supported
Create figures and subplots of the non-linear search specific visualization of every search algorithm supported
by **PyAutoFit**.

The plotting API is **functional**: import ``autofit.plot`` and call a plot function directly, passing it the
``Samples`` object of a completed fit. There are no ``Plotter`` classes.

.. code-block:: python

import autofit.plot as aplt

aplt.corner_cornerpy(samples=result.samples)

**Examples / Tutorials:**

- `readthedocs: non-linear search example <https://pyautofit.readthedocs.io/en/latest/cookbooks/search.html>`_
- `autofit_workspace: plot tutorials <https://github.com/PyAutoLabs/autofit_workspace/tree/main/notebooks/guides/plot>`_
- `HowToFit: tutorial lectures (detailed step-by-step examples) <https://github.com/PyAutoLabs/HowToFit>`_

--------
Plotters
--------
Search Plot Functions [aplt]
----------------------------

.. currentmodule:: autofit.plot

**Posterior Corner Plots:**

.. autosummary::
:toctree: _autosummary

corner_cornerpy
corner_anesthetic

**Sampling Trace Plots:**

.. autosummary::
:toctree: _autosummary

subplot_parameters
log_likelihood_vs_iteration

Figure Output [aplt]
--------------------

Every plot function above takes ``path``, ``filename`` and ``format`` arguments controlling where the figure goes:
``format="show"`` (the default) displays it interactively, whereas ``"png"`` or ``"pdf"`` writes it to
``path/filename.format``. The shared helper that performs this is also public:

.. autosummary::
:toctree: _autosummary
:template: custom-class-template.rst
:recursive:

NestPlotter
MCMCPlotter
MLEPlotter
output_figure
7 changes: 3 additions & 4 deletions docs/cookbooks/samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,11 @@ Sigma = 10.001029545296722

## Search Plots

The Probability Density Functions (PDF's) of the results can be plotted using the Emcee's visualization
tool `corner.py`, which is wrapped via the `EmceePlotter` object.
The Probability Density Functions (PDF's) of the results can be plotted using the visualization
tool `corner.py`, which is wrapped via the `corner_cornerpy` function.

```python
plotter = aplt.MCMCPlotter(samples=result.samples)
plotter.corner()
aplt.corner_cornerpy(samples=result.samples)
```

This plot appears as follows:
Expand Down
18 changes: 7 additions & 11 deletions docs/cookbooks/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,18 @@ search = af.Emcee(number_of_cores=4)

## Plots

Every non-linear search supported by **PyAutoFit** has a dedicated `plotter` class that allows the results of the
model-fit to be plotted and inspected.
The results of a model-fit are plotted and inspected via the plot functions of `autofit.plot`, which wrap the
in-built visualization libraries of the searches. These are fully described in the `plot` package of the workspace.

This uses that search's in-built visualization libraries, which are fully described in the `plot` package of the
workspace.

For example, `Emcee` has a corresponding `EmceePlotter`, which is used as follows.
For example, `corner_cornerpy` wraps `corner.py` and is used as follows.

Checkout the `plot` package for a complete description of the plots that can be made for a given search.

```python
samples = result.samples

plotter = aplt.MCMCPlotter(samples=samples)

plotter.corner(
aplt.corner_cornerpy(
samples=samples,
bins=20,
range=None,
color="k",
Expand Down Expand Up @@ -256,8 +252,8 @@ Information about Emcee can be found at the following links:

The following workspace example shows examples of fitting data with Emcee and plotting the results.

- `autofit_workspace/notebooks/searches/mcmc/Emcee.ipynb`
- `autofit_workspace/notebooks/plot/EmceePlotter.ipynb`
- `autofit_workspace/notebooks/searches/mcmc.ipynb`
- `autofit_workspace/notebooks/plot/emcee_plotter.ipynb`

The following code shows how to use Emcee with all available options.

Expand Down
3 changes: 1 addition & 2 deletions docs/overview/the_basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,7 @@ algorithm (e.g. the internal dynesty samples).
Below we use the samples to plot the probability density function cornerplot of the results.

```python
plotter = aplt.NestPlotter(samples=result.samples)
plotter.corner_anesthetic()
aplt.corner_anesthetic(samples=result.samples)
```

The plot appears as follows:
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx_warning_baseline.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67
31
Loading