Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/hydrodiy/plot/putils.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,8 @@ def bivarnplot(ax, xy, add_semicorr=True, namex="var 1",
ax.set_xlabel(f"Standard normal score for {namex} [-]")
ax.set_ylabel(f"Standard normal score for {namey} [-]")

return unorm, rho, eta, rho_p, rho_m


def waterbalplot(ax, ncoeff=2.5):
""" Background for the normalised P/PE vs Q/P adimensional
Expand Down
13 changes: 10 additions & 3 deletions src/hydrodiy/plot/tests/test_hyplot_putils.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,16 +398,23 @@ def test_scattercat_cat():



def test_bivarnplot():
def test_bivarnplot(allclose):
""" Test categorical scatter plot """
mean = [0, 0]
cov = [[1, 0.7], [0.7, 1]]
xy = np.random.multivariate_normal(mean, cov, size=100)
nsmp = 100000
xy = np.random.multivariate_normal(mean, cov, size=nsmp)
fig, ax = plt.subplots()
putils.bivarnplot(ax, xy)

unorm, rho, eta, rho_p, rho_m = putils.bivarnplot(ax, xy)

fp = FIMG / "bivarnplot.png"
fig.savefig(fp)

assert allclose(rho, 0.7, 1e-2)
assert allclose(rho_p, eta, 1e-2)
assert allclose(rho_m, eta, 1e-2)


def test_waterbalplot():
""" Test categorical scatter plot """
Expand Down