Skip to content

Commit

Permalink
Fixes scaling ranks scaling for negative data, adds the example of th…
Browse files Browse the repository at this point in the history
…e Ishigami function
  • Loading branch information
efekhari27 committed Jul 30, 2023
1 parent b65d23b commit 76f7470
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
11 changes: 9 additions & 2 deletions copulogram/Copulogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ def draw(self,

if quantile_contour_levels is None:
copulogram.map_lower(plt.scatter, color=color, alpha=alpha, marker=marker)
temp = df_numeric.rank() / self.N * df_numeric.max().values
temp = (df_numeric.rank() / self.N)
xmaxs = df_numeric.max().values
xmins = df_numeric.min().values
temp = temp * (xmaxs - xmins) + xmins
copulogram.data = temp
copulogram = copulogram.map_upper(plt.scatter, color=color, alpha=alpha, marker=marker)
else:
Expand Down Expand Up @@ -140,7 +143,11 @@ def draw(self,

if quantile_contour_levels is None:
copulogram.map_lower(sns.scatterplot, alpha=alpha, marker=marker)
temp = df_numeric[plotted_cols].rank() / self.N * df_numeric[plotted_cols].max().values
#temp = df_numeric[plotted_cols].rank() / self.N * df_numeric[plotted_cols].max().values
temp = (df_numeric[plotted_cols].rank() / self.N)
xmaxs = df_numeric[plotted_cols].max().values
xmins = df_numeric[plotted_cols].min().values
temp = temp * (xmaxs - xmins) + xmins
temp[hue] = df[hue]
copulogram.data = temp
copulogram = copulogram.map_upper(sns.scatterplot, alpha=alpha, marker=marker)
Expand Down
Binary file added examples/figures/ishigami.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/wind_waves.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/wind_waves_contours.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/wind_waves_woutput.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions examples/ishigami.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copyright (C) EDF 2023
@author: Elias Fekhari
"""
import numpy as np
import pandas as pd
import openturns as ot
import copulogram as cp
from openturns.usecases import ishigami_function

im = ishigami_function.IshigamiModel()
size = 5000
X = im.distributionX.getSample(size)
Y = im.model(X)

plotting_size = 1000
data = pd.DataFrame(np.array(X[:plotting_size]), columns=list(X.getDescription()))
data['Y'] = np.array(Y[:plotting_size])
copulogram = cp.Copulogram(data)
copulogram.draw(color='C7', marker='.', alpha=0.5, save_file="figures/ishigami.jpg")

0 comments on commit 76f7470

Please sign in to comment.