File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
bayesflow/diagnostics/plots Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 44import pandas as pd
55import seaborn as sns
66
7+ import matplotlib .pyplot as plt
8+
79from bayesflow .utils import logging
810from bayesflow .utils .dict_utils import dicts_to_arrays
911
@@ -122,7 +124,7 @@ def _pairs_samples(
122124
123125 # add histograms + KDEs to the diagonal
124126 g .map_diag (
125- sns . histplot ,
127+ histplot_twinx ,
126128 fill = True ,
127129 kde = True ,
128130 color = color ,
@@ -169,3 +171,23 @@ def _pairs_samples(
169171 g .tight_layout ()
170172
171173 return g
174+
175+
176+ # create a histogram plot on a twin y axis
177+ # this ensures that the y scaling of the diagonal plots
178+ # in independent of the y scaling of the off-diagonal plots
179+ def histplot_twinx (x , ** kwargs ):
180+ # Create a twin axis
181+ ax2 = plt .gca ().twinx ()
182+
183+ # create a histogram on the twin axis
184+ sns .histplot (x , ** kwargs , ax = ax2 )
185+
186+ # make the twin axis invisible
187+ plt .gca ().spines ["right" ].set_visible (False )
188+ plt .gca ().spines ["top" ].set_visible (False )
189+ ax2 .set_ylabel ("" )
190+ ax2 .set_yticks ([])
191+ ax2 .set_yticklabels ([])
192+
193+ return None
You can’t perform that action at this time.
0 commit comments