File wellmet/mplot/maxes.py changed (mode: 100644) (index 288a7be..766ada5) |
... |
... |
from matplotlib import lines as mlines |
24 |
24 |
|
|
25 |
25 |
# it is mostly for qt_plot, it offers availiable options to user |
# it is mostly for qt_plot, it offers availiable options to user |
26 |
26 |
__all__ = [ |
__all__ = [ |
|
27 |
|
'GRaph', |
27 |
28 |
'rbf_plot', 'rbf_density_plot', 'rbf_diagram', |
'rbf_plot', 'rbf_density_plot', 'rbf_diagram', |
28 |
29 |
'candidates_plot', 'rejection_sampling_plot', |
'candidates_plot', 'rejection_sampling_plot', |
29 |
30 |
'candidates_sampling_plot', |
'candidates_sampling_plot', |
|
... |
... |
__all__ = [ |
42 |
43 |
] |
] |
43 |
44 |
|
|
44 |
45 |
|
|
|
46 |
|
def GRaph(ax, df=None, ls='', **kwargs): |
|
47 |
|
from .. import sball |
|
48 |
|
ax.margins(0) |
|
49 |
|
#ax.yaxis.set_ticks_position('right') |
|
50 |
|
#ax.yaxis.set_label_position('right') |
|
51 |
|
ax.set_xlabel(r"Limit-state evaluations, $N_{\mathrm{sim}}$") |
|
52 |
|
ax.set_ylabel("$r$") |
|
53 |
|
|
|
54 |
|
s_ball = sball.Sball(ax.sample_box.nvar) |
|
55 |
|
|
|
56 |
|
|
|
57 |
|
secax = ax.secondary_yaxis(1, functions=(s_ball.sf, s_ball.isf)) |
|
58 |
|
secax.set_ylabel("$S_{\chi} (r; N_{\mathrm{var}})$") |
|
59 |
|
secax.yaxis.set_major_locator(ticker.LogLocator()) |
|
60 |
|
secax.yaxis.set_major_formatter(ticker.LogFormatterMathtext()) |
|
61 |
|
|
|
62 |
|
lengths = np.sum(np.square(ax.sample_box.G), axis=1) |
|
63 |
|
lengths = np.sqrt(lengths, out=lengths) #lengths of each radius-vector |
|
64 |
|
|
|
65 |
|
x = np.arange(len(lengths)) + 1 |
|
66 |
|
y = lengths |
|
67 |
|
|
|
68 |
|
failsi = ax.sample_box.failsi |
|
69 |
|
|
|
70 |
|
try: # proxy denotes to implicitly-known values |
|
71 |
|
proxy = ax.sample_box.proxy.astype(bool) |
|
72 |
|
except AttributeError: |
|
73 |
|
proxy = np.full(len(lengths), False, dtype=np.bool) |
|
74 |
|
|
|
75 |
|
|
|
76 |
|
#č byl jsem svědkem, že matplotlib zlobil ve 3D |
|
77 |
|
#č kvůli tomu, že nebyl žádný safe vzorek |
|
78 |
|
#č proto raději budu přidávat tečky podmíněne |
|
79 |
|
mask = np.all((~failsi, ~proxy), axis=0) |
|
80 |
|
if np.any(mask): #success |
|
81 |
|
ax.plot(x[mask], y[mask], mec='g', mfc='g', marker='P', ls=ls, **kwargs) |
|
82 |
|
|
|
83 |
|
mask = np.all((failsi, ~proxy), axis=0) |
|
84 |
|
if np.any(mask): #failures |
|
85 |
|
ax.plot(x[mask], y[mask], mec='r', mfc='r', marker='X', ls=ls, **kwargs) |
|
86 |
|
|
|
87 |
|
mask = np.all((~failsi, proxy), axis=0) |
|
88 |
|
if np.any(mask): #proxy_successes |
|
89 |
|
ax.plot(x[mask], y[mask], |
|
90 |
|
mec='#77AC30', mfc=(0,0,0,0), marker='h', ls=ls, **kwargs) |
|
91 |
|
|
|
92 |
|
mask = np.all((failsi, proxy), axis=0) |
|
93 |
|
if np.any(mask): #proxy_failures |
|
94 |
|
ax.plot(x[mask], y[mask], |
|
95 |
|
mec='#D95319', mfc=(0,0,0,0), marker='H', ls=ls, **kwargs) |
|
96 |
|
|
|
97 |
|
|
|
98 |
|
if np.any(failsi): |
|
99 |
|
ax.axhline(np.min(y[failsi]), c='r', zorder=-1, **kwargs) |
|
100 |
|
|
|
101 |
|
if df is None: |
|
102 |
|
try: |
|
103 |
|
import pandas as pd |
|
104 |
|
df = pd.DataFrame(ax.sample_box.box_estimations) |
|
105 |
|
except BaseException as e: |
|
106 |
|
print(repr(e)) |
|
107 |
|
return |
|
108 |
|
|
|
109 |
|
x = df.nsim.to_numpy() |
|
110 |
|
r = df.r.to_numpy() |
|
111 |
|
R = df.R.to_numpy() |
|
112 |
|
ax.fill_between(x, R, y2=0, color='#C3C3C3', step='post', zorder=-20) |
|
113 |
|
ax.fill_between(x, r, y2=0, color='#FFFFFF', step='post', zorder=-10) |
|
114 |
|
ax.set_facecolor('#E1E1E1') |
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
45 |
121 |
def rbf_diagram(ax): |
def rbf_diagram(ax): |
46 |
122 |
from .. import misc as wmisc |
from .. import misc as wmisc |
47 |
123 |
rbf_stm = [] |
rbf_stm = [] |