Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plot_forest and tests #34

Merged
merged 17 commits into from
Mar 28, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
fail-fast: false
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# arviz-plots

[![Run tests](https://github.com/arviz-devs/arviz-plots/actions/workflows/test.yml/badge.svg)](https://github.com/arviz-devs/arviz-plots/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/arviz-devs/arviz-plots/graph/badge.svg?token=1VIPLXCOJQ)](https://codecov.io/gh/arviz-devs/arviz-plots)
[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](https://numfocus.org)

ArviZ plotting elements and static battery included plots
Expand Down
2 changes: 2 additions & 0 deletions docs/source/api/backend/interface.template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Plot appeareance
title
ylabel
xlabel
xticks
yticks
ticks_size
remove_ticks
remove_axis
Expand Down
1 change: 1 addition & 0 deletions docs/source/api/plots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ A complementary introduction and guide to ``plot_...`` functions is available at
:toctree: generated/

plot_dist
plot_forest
plot_trace
plot_trace_dist
1 change: 1 addition & 0 deletions docs/source/api/visuals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Data and axis annotating elements
.. autosummary::
:toctree: generated/

annotate_label
point_estimate_text
labelled_title
labelled_y
Expand Down
12 changes: 11 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"sphinx_copybutton",
"sphinx_design",
"jupyter_sphinx",
"matplotlib.sphinxext.plot_directive",
]

templates_path = ["_templates"]
Expand Down Expand Up @@ -67,11 +68,19 @@

# -- Options for extensions

plot_include_source = True
plot_formats = [("png", 90)]
plot_html_show_formats = False
plot_html_show_source_link = False

extlinks = {
"issue": ("https://github.com/arviz-devs/arviz-base/issues/%s", "GH#%s"),
"pull": ("https://github.com/arviz-devs/arviz-base/pull/%s", "PR#%s"),
}

copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
copybutton_prompt_is_regexp = True

nb_execution_mode = "auto"
nb_execution_excludepatterns = ["*.ipynb"]
nb_kernel_rgx_aliases = {".*": "python3"}
Expand All @@ -85,12 +94,13 @@

numpydoc_show_class_members = False
numpydoc_xref_param_type = True
numpydoc_xref_ignore = {"of", "or", "optional", "scalar"}
numpydoc_xref_ignore = {"of", "or", "optional", "scalar", "default"}
singulars = ("int", "list", "dict", "float")
numpydoc_xref_aliases = {
"DataArray": ":class:`xarray.DataArray`",
"Dataset": ":class:`xarray.Dataset`",
"DataTree": ":class:`datatree.DataTree`",
"mapping": ":term:`python:mapping`",
**{f"{singular}s": f":any:`{singular}s <{singular}>`" for singular in singulars},
}

Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
[project]
name = "arviz-plots"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
license = {file = "LICENSE"}
authors = [
{name = "ArviZ team", email = "[email protected]"}
Expand All @@ -20,9 +20,9 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version", "description"]
dependencies = [
Expand All @@ -45,7 +45,8 @@ test = [
"pytest",
"pytest-cov",
"matplotlib",
"bokeh"
"bokeh",
"h5netcdf",
]
doc = [
"furo",
Expand Down Expand Up @@ -110,6 +111,7 @@ disallow_untyped_defs = true
# ignore_missing_imports = true

[tool.pytest.ini_options]
filterwarnings = ["error"]
testpaths = [
"tests",
]
Expand Down
55 changes: 54 additions & 1 deletion src/arviz_plots/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
to any type of the plotting backend or even custom objects, but all instances
of the same placeholder must use the same type (whatever that is).
"""
import numpy as np

error = NotImplementedError(
"The `arviz_plots.backend` module itself is for reference only. "
Expand All @@ -20,6 +21,22 @@
)


# generation of default values for aesthetics
def get_default_aes(aes_key, n, kwargs):
"""Generate `n` default values for a given aesthetics keyword."""
if aes_key not in kwargs:
if aes_key in {"x", "y"}:
return np.arange(n)
if aes_key == "alpha":
return np.linspace(0.2, 0.7, n)
return [None] * n
aes_vals = kwargs[aes_key]
n_aes_vals = len(aes_vals)
if n_aes_vals >= n:
return aes_vals[:n]
return np.tile(aes_vals, (n // n_aes_vals) + 1)[:n]


# object creation and i/o
def show(chart):
"""Show this :term:`chart`.
Expand All @@ -39,6 +56,8 @@ def create_plotting_grid(
sharex=False,
sharey=False,
polar=False,
width_ratios=None,
plot_hspace=None,
subplot_kws=None,
**kwargs,
):
Expand All @@ -56,6 +75,8 @@ def create_plotting_grid(
Flags that indicate the axis limits between the different plots should
be shared.
polar : bool, default False
width_ratios : array_like of shape (cols,), optional
plot_hspace : float, optional
subplot_kws, **kwargs : mapping, optional
Arguments passed downstream to the plotting backend.

Expand Down Expand Up @@ -114,9 +135,10 @@ def scatter(
target : plot type
size : float or array-like of float
marker : any
The character ``|`` must be a valid marker as it is the default for rug plots.
alpha : float
color : any
Set both facecolor and edgecolor simultaneously.
Set both facecolor and edgecolor simultaneously but without overriding them if present.
facecolor : any
Color of the marker filling.
edgecolor : any
Expand Down Expand Up @@ -145,6 +167,11 @@ def text(
raise error


def fill_between_y(x, y_bottom, y_top, target, **artist_kws):
"""Fill the region between y_bottom and y_top."""
raise error


# general plot appeareance
def title(string, target, *, size=None, color=None, **artist_kws):
"""Interface to adding a title to a plot."""
Expand All @@ -161,6 +188,32 @@ def xlabel(string, target, *, size=None, color=None, **artist_kws):
raise error


def xticks(ticks, labels, traget, **artist_kws):
"""Interface to setting ticks and tick labels of the x axis.

Parameters
----------
ticks : array_like
labels : array_like or None
Labels for the provided `ticks`. Must accept ``None`` as a way
to set only ticks and leave their default labels.
"""
raise error


def yticks(ticks, labels, traget, **artist_kws):
"""Interface to setting ticks and tick labels of the y axis.

Parameters
----------
ticks : array_like
labels : array_like or None
Labels for the provided `ticks`. Must accept ``None`` as a way
to set only ticks and leave their default labels.
"""
raise error


def ticks_size(value, target):
"""Interface to setting ticks size."""
raise error
Expand Down
Loading
Loading