Skip to content

Commit

Permalink
first commit for mcse plot
Browse files Browse the repository at this point in the history
  • Loading branch information
imperorrp committed Aug 5, 2024
1 parent 1298e42 commit db0b5f7
Show file tree
Hide file tree
Showing 5 changed files with 604 additions and 1 deletion.
37 changes: 37 additions & 0 deletions src/arviz_plots/backend/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Sets ``zorder`` of all non-text "geoms" to ``2`` so that elements plotted later
on are on top of previous ones.
"""

import warnings
from typing import Any, Dict

Expand Down Expand Up @@ -244,6 +245,42 @@ def scatter(
return target.scatter(x, y, **_filter_kwargs(kwargs, None, artist_kws))


def errorbar(
x,
y,
error,
target,
*,
size=unset,
marker=unset,
color=unset,
facecolor=unset,
edgecolor=unset,
width=unset,
**artist_kws,
):
"""Interface to matplotlib for an errorbar plot."""
artist_kws.setdefault("zorder", 2)
fillable_marker = (marker is unset) or (marker in Line2D.filled_markers)
if color is not unset:
if facecolor is unset and edgecolor is unset:
facecolor = color
if fillable_marker:
edgecolor = color
elif facecolor is unset:
facecolor = color
elif edgecolor is unset and fillable_marker:
edgecolor = color
kwargs = {
"capsize": size,
"marker": marker,
"markerfacecolor": facecolor,
"markeredgecolor": edgecolor,
"elinewidth": width,
}
return target.errorbar(x, y, error, **_filter_kwargs(kwargs, None, artist_kws))


def text(
x,
y,
Expand Down
43 changes: 43 additions & 0 deletions src/arviz_plots/backend/none/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,49 @@ def scatter(
return artist_element


def errorbar(
x,
y,
error,
target,
*,
size=unset,
marker=unset,
color=unset,
facecolor=unset,
edgecolor=unset,
width=unset,
**artist_kws,
):
"""Interface to an errorbar plot."""
if color is not unset:
if facecolor is unset and edgecolor is unset:
facecolor = color
edgecolor = color
elif facecolor is unset:
facecolor = color
elif edgecolor is unset:
edgecolor = color
kwargs = {
"capsize": size,
"marker": marker,
"markerfacecolor": facecolor,
"markeredgecolor": edgecolor,
"elinewidth": width,
}
if not ALLOW_KWARGS and artist_kws:
raise ValueError("artist_kws not empty")
artist_element = {
"function": "errorbar",
"x": np.atleast_1d(x),
"y": np.atleast_1d(y),
"error": np.atleast_1d(error),
**_filter_kwargs(kwargs, artist_kws),
}
target.append(artist_element)
return artist_element


def text(
x,
y,
Expand Down
3 changes: 2 additions & 1 deletion src/arviz_plots/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from .distplot import plot_dist
from .forestplot import plot_forest
from .mcseplot import plot_mcse
from .ridgeplot import plot_ridge
from .tracedistplot import plot_trace_dist
from .traceplot import plot_trace

__all__ = ["plot_dist", "plot_forest", "plot_trace", "plot_trace_dist", "plot_ridge"]
__all__ = ["plot_dist", "plot_forest", "plot_trace", "plot_trace_dist", "plot_ridge", "plot_mcse"]
Loading

0 comments on commit db0b5f7

Please sign in to comment.