|
11 | 11 | import pandas as pd |
12 | 12 | from pandas.io.formats.style import Styler |
13 | 13 | import panel as pn |
14 | | -import seaborn as sns |
15 | 14 |
|
16 | 15 | import simdec as sd |
17 | 16 | from simdec.sensitivity_indices import SensitivityAnalysisResult |
|
43 | 42 | ) |
44 | 43 |
|
45 | 44 | VALID_CHARACTERS = re.compile(r"[^A-Za-z0-9_ \-.]") |
46 | | -try: |
47 | | - DEFAULT_STRESS_CSV = Path(__file__).resolve().parent / "data" / "stress.csv" |
48 | | -except NameError: |
| 45 | +# try: |
| 46 | +# DEFAULT_STRESS_CSV = Path(__file__).resolve().parent / "data" / "stress.csv" |
| 47 | +# except NameError: |
| 48 | +# DEFAULT_STRESS_CSV = Path("data/stress.csv") |
| 49 | +if Path("data/stress.csv").exists(): |
49 | 50 | DEFAULT_STRESS_CSV = Path("data/stress.csv") |
| 51 | +else: |
| 52 | + # Fallback for if the zip was flattened or file is in the root |
| 53 | + DEFAULT_STRESS_CSV = Path("stress.csv") |
50 | 54 | GENERIC_ERROR_MSG = ( |
51 | 55 | "Could not parse the CSV file. " |
52 | 56 | "Please check that it uses commas ',' as the delimiter " |
@@ -262,49 +266,18 @@ def figure_pn( |
262 | 266 | ax.set(xlabel=output_name) |
263 | 267 | ax.set_xlim(xlim) |
264 | 268 | else: |
265 | | - fig, axs = plt.subplots(2, 2, sharex="col", sharey="row", figsize=(8, 8)) |
266 | | - |
267 | | - axs[0][1].axison = False |
268 | | - |
269 | | - _ = sd.visualization( |
| 269 | + fig, _ = sd.two_output_visualization( |
270 | 270 | bins=res.bins, |
| 271 | + bins2=res2.bins, |
271 | 272 | palette=palette, |
272 | 273 | n_bins=n_bins, |
273 | | - kind="histogram", |
274 | | - ax=axs[0][0], |
275 | | - ) |
276 | | - axs[0][0].set_xlim(xlim) |
277 | | - axs[0][0].set_box_aspect(aspect=1) |
278 | | - axs[0][0].axis("off") |
279 | | - |
280 | | - data = pd.concat([pd.melt(res.bins), pd.melt(res2.bins)["value"]], axis=1) |
281 | | - data.columns = ["c", "x", "y"] |
282 | | - data = data.sample(int(r_scatter * len(data))) |
283 | | - _ = sns.scatterplot( |
284 | | - data, x="x", y="y", hue="c", palette=palette, ax=axs[1][0], legend=False |
285 | | - ) |
286 | | - axs[1][0].set(xlabel=output_name) |
287 | | - axs[1][0].set(ylabel=output_2_name) |
288 | | - axs[1][0].set_box_aspect(aspect=1) |
289 | | - |
290 | | - _ = sns.histplot( |
291 | | - data, |
292 | | - y="y", |
293 | | - hue="c", |
294 | | - multiple="stack", |
295 | | - stat="probability", |
296 | | - palette=palette, |
297 | | - common_bins=True, |
298 | | - common_norm=True, |
299 | | - bins=40, |
300 | | - legend=False, |
301 | | - ax=axs[1][1], |
| 274 | + output_name=output_name, |
| 275 | + output_name2=output_2_name, |
| 276 | + xlim=xlim, |
| 277 | + ylim=ylim, |
| 278 | + r_scatter=r_scatter, |
302 | 279 | ) |
303 | | - axs[1][1].set_ylim(ylim) |
304 | | - axs[1][1].set_box_aspect(aspect=1) |
305 | | - axs[1][1].axis("off") |
306 | 280 |
|
307 | | - fig.subplots_adjust(wspace=-0.015, hspace=0) |
308 | 281 | return fig |
309 | 282 |
|
310 | 283 |
|
|
0 commit comments