Skip to content

Commit acea150

Browse files
authored
feat: added bivarnplot outputs (#49)
1 parent 6d538bb commit acea150

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/hydrodiy/plot/putils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,8 @@ def bivarnplot(ax, xy, add_semicorr=True, namex="var 1",
871871
ax.set_xlabel(f"Standard normal score for {namex} [-]")
872872
ax.set_ylabel(f"Standard normal score for {namey} [-]")
873873

874+
return unorm, rho, eta, rho_p, rho_m
875+
874876

875877
def waterbalplot(ax, ncoeff=2.5):
876878
""" Background for the normalised P/PE vs Q/P adimensional

src/hydrodiy/plot/tests/test_hyplot_putils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,23 @@ def test_scattercat_cat():
398398

399399

400400

401-
def test_bivarnplot():
401+
def test_bivarnplot(allclose):
402402
""" Test categorical scatter plot """
403403
mean = [0, 0]
404404
cov = [[1, 0.7], [0.7, 1]]
405-
xy = np.random.multivariate_normal(mean, cov, size=100)
405+
nsmp = 100000
406+
xy = np.random.multivariate_normal(mean, cov, size=nsmp)
406407
fig, ax = plt.subplots()
407-
putils.bivarnplot(ax, xy)
408+
409+
unorm, rho, eta, rho_p, rho_m = putils.bivarnplot(ax, xy)
410+
408411
fp = FIMG / "bivarnplot.png"
409412
fig.savefig(fp)
410413

414+
assert allclose(rho, 0.7, 1e-2)
415+
assert allclose(rho_p, eta, 1e-2)
416+
assert allclose(rho_m, eta, 1e-2)
417+
411418

412419
def test_waterbalplot():
413420
""" Test categorical scatter plot """

0 commit comments

Comments
 (0)