Skip to content

Commit

Permalink
Making plotting functions easier to read
Browse files Browse the repository at this point in the history
  • Loading branch information
Samreay committed Oct 9, 2023
1 parent 547c120 commit 30bd84c
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 341 deletions.
6 changes: 3 additions & 3 deletions docs/examples/plot_0_contours.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Here's a convenience function for you
chain2 = Chain.from_covariance(
[3.0, 1.0],
[[1.0, -0.7], [-0.7, 1.5]],
[[1.0, -1], [-1, 2]],
columns=["A", "B"],
name="Another contour!",
color="#065f46",
Expand All @@ -43,7 +43,7 @@
# let's add markers and truth values.

c.add_marker(location={"A": 0, "B": 2}, name="A point", color="orange", marker_style="P", marker_size=50)
c.add_truth(Truth(location={"A": 0, "B": 1}))
c.add_truth(Truth(location={"A": 0, "B": 5}))
fig = c.plotter.plot()


Expand Down Expand Up @@ -81,7 +81,7 @@
# Notice that Chain is a child of ChainConfig
# So you could override base properties like line weights... but not samples
c.set_override(ChainConfig(sigmas=[0, 1, 2, 3]))
c.add_truth(Truth(location={"A": 0, "B": 1}, color="#500724"))
c.add_truth(Truth(location={"A": 0, "B": 5}, color="#500724"))

# And if we want to change the plot itself in some way, we can do that via
c.set_plot_config(
Expand Down
2 changes: 1 addition & 1 deletion src/chainconsumer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .chainconsumer import ChainConsumer
from .color_finder import colors
from .examples import make_sample
from .plotter import PlotConfig
from .plotting.config import PlotConfig
from .truth import Truth

__all__ = ["ChainConsumer", "Chain", "ChainConfig", "Truth", "PlotConfig", "make_sample", "Bound", "colors"]
Expand Down
2 changes: 1 addition & 1 deletion src/chainconsumer/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def make_sample(
diag = np.sqrt(np.diag(cov))
outer = np.outer(diag, diag)
cor = cov / outer
means = np.arange(num_dimensions) * 1.0
means = np.arange(num_dimensions) * 5.0
if randomise_mean:
means += gen.uniform(-1, 1, num_dimensions)
norm = mv(mean=means, cov=cor)
Expand Down
8 changes: 4 additions & 4 deletions src/chainconsumer/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def get_smoothed_bins(

def get_smoothed_histogram2d(
chain: Chain,
col1: str,
col2: str,
px: str,
py: str,
) -> tuple[np.ndarray, np.ndarray, np.ndarray]: # pragma: no cover
"""Returns a smoothed 2D histogram of two parameters.
Expand All @@ -88,8 +88,8 @@ def get_smoothed_histogram2d(
Returns:
tuple[np.ndarray, np.ndarray, np.ndarray]: The histogram, x bin enters, y bin centers
"""
x = chain.get_data(col1)
y = chain.get_data(col2)
x = chain.get_data(px)
y = chain.get_data(py)
w = chain.weights

if chain.grid:
Expand Down
Loading

0 comments on commit 30bd84c

Please sign in to comment.