Trying to set x-limits on my posterior plot #115
-
Hi folks! I have been trying to use ChainConsumer to plot the posterior from my MCMC and it looks like adding the 'extents' argument does nothing for my plot. I am also unable to import PlotConfig from ChainConsumer. Any help would be appreciated. Details below: Versions: Code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So I did find an issue with the latest version of Chainconsumer in this, but it wasn't to do with the extents. Also, you may have your environment misconfigured, because the code you provided only works on ChainConsumer <1 (as you note with the failing import) If you update to 1.0.3, this code should give you what you want: import pandas as pd
from chainconsumer import Chain, ChainConsumer, PlotConfig, Truth
df = pd.read_csv("pk50.log", sep=r"\s+", header=None, names=["mass", "something"])
chain = Chain(samples=df[["mass"]], name="CV+noise", color="#F28482")
df_truth = pd.read_csv("params_LH.txt", sep=r"\s+", header=None, names=["mass", "something"])
truth = Truth(location={"mass": df_truth["mass"].iloc[50]})
config = PlotConfig(labels={"mass": r"$M_{(h, {\rm min})}(\rm 10^{10} M_\odot)$"}, extents={"mass": (2, 8)})
c = ChainConsumer()
c.add_chain(chain)
c.add_truth(truth)
c.set_plot_config(config)
fig = c.plotter.plot(figsize=(6, 4), filename="tmp.png") Also, if you want the bars to look smoother when zoomed in, try adding |
Beta Was this translation helpful? Give feedback.
So I did find an issue with the latest version of Chainconsumer in this, but it wasn't to do with the extents. Also, you may have your environment misconfigured, because the code you provided only works on ChainConsumer <1 (as you note with the failing import)
If you update to 1.0.3, this code should give you what you want: