File mplot/mart3d.py changed (mode: 100644) (index b1d3eab..2d36710) |
... |
... |
def get_g_model_wireframe_data(shape_share, limits, space='R', ngrid=50): |
58 |
58 |
# ax.space and ax.sample_box attributes should (expected to) be set up! |
# ax.space and ax.sample_box attributes should (expected to) be set up! |
59 |
59 |
|
|
60 |
60 |
|
|
61 |
|
def scatter_points(ax3d, zs=None, **kwargs): |
|
|
61 |
|
def scatter_points(ax3d, zs=None, markers=('P', 'X', 'h', 'H'), **kwargs): |
62 |
62 |
sample = getattr(ax3d.sample_box, ax3d.space) |
sample = getattr(ax3d.sample_box, ax3d.space) |
63 |
63 |
nsim = len(sample) |
nsim = len(sample) |
64 |
64 |
if zs is not None: |
if zs is not None: |
|
... |
... |
def scatter_points(ax3d, zs=None, **kwargs): |
77 |
77 |
except AttributeError: |
except AttributeError: |
78 |
78 |
proxy = np.full(nsim, False, dtype=np.bool) |
proxy = np.full(nsim, False, dtype=np.bool) |
79 |
79 |
|
|
|
80 |
|
sm, fm, psm, pfm = markers |
80 |
81 |
|
|
81 |
82 |
mask = np.all((~failsi, ~proxy), axis=0) |
mask = np.all((~failsi, ~proxy), axis=0) |
82 |
|
success = ax3d.scatter(x[mask], y[mask], zs=zs[mask], c='g', marker='P', **kwargs) |
|
|
83 |
|
success = ax3d.scatter(x[mask], y[mask], zs=zs[mask], c='g', marker=sm, **kwargs) |
83 |
84 |
|
|
84 |
85 |
mask = np.all((failsi, ~proxy), axis=0) |
mask = np.all((failsi, ~proxy), axis=0) |
85 |
|
failures = ax3d.scatter(x[mask], y[mask], zs=zs[mask], c='r', marker='X', **kwargs) |
|
|
86 |
|
failures = ax3d.scatter(x[mask], y[mask], zs=zs[mask], c='r', marker=fm, **kwargs) |
86 |
87 |
|
|
87 |
88 |
mask = np.all((~failsi, proxy), axis=0) |
mask = np.all((~failsi, proxy), axis=0) |
88 |
89 |
proxy_successes = ax3d.scatter(x[mask], y[mask], zs=zs[mask],\ |
proxy_successes = ax3d.scatter(x[mask], y[mask], zs=zs[mask],\ |
89 |
|
c='#77AC30', marker='h', **kwargs) |
|
|
90 |
|
c='#77AC30', marker=psm, **kwargs) |
90 |
91 |
|
|
91 |
92 |
mask = np.all((failsi, proxy), axis=0) |
mask = np.all((failsi, proxy), axis=0) |
92 |
93 |
proxy_failures = ax3d.scatter(x[mask], y[mask], zs=zs[mask],\ |
proxy_failures = ax3d.scatter(x[mask], y[mask], zs=zs[mask],\ |
93 |
|
c='#D95319', marker='H', **kwargs) |
|
|
94 |
|
c='#D95319', marker=pfm, **kwargs) |
94 |
95 |
|
|
95 |
96 |
return success, failures, proxy_successes, proxy_failures |
return success, failures, proxy_successes, proxy_failures |
96 |
97 |
|
|
97 |
98 |
|
|
98 |
99 |
|
|
|
100 |
|
def plot_points(ax3d, zs=None, markers=('P', 'X', 'h', 'H'), ls='', **kwargs): |
|
101 |
|
sample = getattr(ax3d.sample_box, ax3d.space) |
|
102 |
|
nsim = len(sample) |
|
103 |
|
if zs is not None: |
|
104 |
|
x, y = sample[:,:2].T |
|
105 |
|
elif ax3d.sample_box.nvar == 2: |
|
106 |
|
x, y = sample[:,:2].T |
|
107 |
|
#zs = ax3d.sample_box.pdf(ax3d.space) |
|
108 |
|
zs = ax3d.sample_box.g_values |
|
109 |
|
else: |
|
110 |
|
x, y, zs = sample[:,:3].T |
|
111 |
|
|
|
112 |
|
failsi = ax3d.sample_box.failsi |
|
113 |
|
|
|
114 |
|
try: # proxy denotes to implicitly-known values |
|
115 |
|
proxy = ax3d.sample_box.proxy |
|
116 |
|
except AttributeError: |
|
117 |
|
proxy = np.full(nsim, False, dtype=np.bool) |
|
118 |
|
|
|
119 |
|
sm, fm, psm, pfm = markers |
|
120 |
|
|
|
121 |
|
plot_list = [] |
|
122 |
|
|
|
123 |
|
#č byl jsem svědkem, že matplotlib zlobil ve 3D |
|
124 |
|
#č kvůli tomu, že nebyl žádný safe vzorek |
|
125 |
|
#č proto raději budu přidávat tečky podmíněne |
|
126 |
|
mask = np.all((~failsi, ~proxy), axis=0) |
|
127 |
|
if np.any(mask): #success |
|
128 |
|
plot_list.append(ax3d.plot(x[mask], y[mask], mec='g', mfc='g',\ |
|
129 |
|
marker=sm, ls=ls, **kwargs)) |
|
130 |
|
|
|
131 |
|
mask = np.all((failsi, ~proxy), axis=0) |
|
132 |
|
if np.any(mask): #failures |
|
133 |
|
plot_list.append(ax3d.plot(x[mask], y[mask], mec='r', mfc='r',\ |
|
134 |
|
marker=fm, ls=ls, **kwargs)) |
|
135 |
|
|
|
136 |
|
mask = np.all((~failsi, proxy), axis=0) |
|
137 |
|
if np.any(mask): #proxy_successes |
|
138 |
|
plot_list.append(ax3d.plot(x[mask], y[mask], mec='#77AC30', mfc=(0,0,0,0),\ |
|
139 |
|
marker=psm, ls=ls, **kwargs)) |
|
140 |
|
|
|
141 |
|
mask = np.all((failsi, proxy), axis=0) |
|
142 |
|
if np.any(mask): #proxy_failures |
|
143 |
|
plot_list.append(ax3d.plot(x[mask], y[mask], mec='#D95319', mfc=(0,0,0,0),\ |
|
144 |
|
marker=pfm, ls=ls, **kwargs)) |
|
145 |
|
|
|
146 |
|
return plot_list # success, failures, proxy_successes, proxy_failures |
|
147 |
|
|
|
148 |
|
|
99 |
149 |
|
|
100 |
150 |
def tri_plot(ax, Tri=None, fmt='-', ns=100, **kwargs): |
def tri_plot(ax, Tri=None, fmt='-', ns=100, **kwargs): |
101 |
151 |
if ax.sample_box.nvar == 3: |
if ax.sample_box.nvar == 3: |
File mplot/maxes3d.py changed (mode: 100644) (index f98db2a..af012d1) |
... |
... |
from . import mart |
14 |
14 |
from . import mart3d |
from . import mart3d |
15 |
15 |
|
|
16 |
16 |
# it is mostly for qt_plot, it offers availiable options to user |
# it is mostly for qt_plot, it offers availiable options to user |
17 |
|
__all__ = ['tri_plot', 'plot3D', 'candidates_drawing', 'plane_under_density', 'qhull_under_density', 'dhull_under_density'] |
|
|
17 |
|
__all__ = ['tri_plot', 'plot3D', 'plot_points_3D', |
|
18 |
|
'candidates_drawing', 'plane_under_density', |
|
19 |
|
'qhull_under_density', 'dhull_under_density'] |
18 |
20 |
|
|
19 |
21 |
def plot3D(ax3d): |
def plot3D(ax3d): |
20 |
22 |
mart3d.scatter_points(ax3d) |
mart3d.scatter_points(ax3d) |
|
... |
... |
def plot3D(ax3d): |
24 |
26 |
ax3d.set_zlabel("$x_3$") |
ax3d.set_zlabel("$x_3$") |
25 |
27 |
|
|
26 |
28 |
|
|
|
29 |
|
def plot_points_3D(ax3d): |
|
30 |
|
mart3d.scatter_points(ax3d, markers=('.', '.', '.', '.'), alpha=0.5, rasterized=True) |
|
31 |
|
|
|
32 |
|
ax3d.set_xlabel("$x_1$") |
|
33 |
|
ax3d.set_ylabel("$x_2$") |
|
34 |
|
ax3d.set_zlabel("$x_3$") |
|
35 |
|
|
27 |
36 |
|
|
28 |
37 |
#č ten [plot] zásadně vytvaří své struktury, nepouzívá oné ze skříňky, |
#č ten [plot] zásadně vytvaří své struktury, nepouzívá oné ze skříňky, |
29 |
38 |
#č protože já vím, že v těch obrázcích, ve kterých chcu ho použit, |
#č protože já vím, že v těch obrázcích, ve kterých chcu ho použit, |
File mplot/mfigs.py changed (mode: 100644) (index deabcb5..454f2f5) |
... |
... |
from matplotlib import ticker |
14 |
14 |
|
|
15 |
15 |
__all__ = [ |
__all__ = [ |
16 |
16 |
'convergence_diagram', 'convergence_legend', 'double_proxy_diagram', |
'convergence_diagram', 'convergence_legend', 'double_proxy_diagram', |
17 |
|
'four_branch_convergence', 'beta_diagram', 'suspension_3d', |
|
|
17 |
|
'four_branch_convergence', 'beta_diagram', 'double_diagram', 'suspension_3d', |
18 |
18 |
'double_tri_R_plot', 'double_tri_R_twins_plot', 'double_plot', |
'double_tri_R_plot', 'double_tri_R_twins_plot', 'double_plot', |
19 |
19 |
'double_pprod_R_plot', 'double_mprod_R_plot', |
'double_pprod_R_plot', 'double_mprod_R_plot', |
20 |
20 |
'triple_plot', 'triple_wide', 'triple_wide_50_100', 'triple_plot_50_100', |
'triple_plot', 'triple_wide', 'triple_wide_50_100', 'triple_plot_50_100', |
|
... |
... |
def four_branch_convergence(fig, sample_box, space, lim=100): |
92 |
92 |
ax.xaxis.set_major_formatter(ticker.FixedFormatter(seq)) |
ax.xaxis.set_major_formatter(ticker.FixedFormatter(seq)) |
93 |
93 |
ax.xaxis.set_major_locator(ticker.FixedLocator(locs=ticks)) |
ax.xaxis.set_major_locator(ticker.FixedLocator(locs=ticks)) |
94 |
94 |
|
|
|
95 |
|
def double_diagram(fig, sample_box, space, lim=1000): |
|
96 |
|
ax1 = ax = fig.add_subplot(211) |
|
97 |
|
ax.sample_box = sample_box |
|
98 |
|
maxes.convergence_diagram(ax) |
|
99 |
|
ax.set_xlim(0, lim) |
|
100 |
|
ax.set_xlabel('') |
|
101 |
|
|
|
102 |
|
ax = fig.add_subplot(212) |
|
103 |
|
ax.sample_box = sample_box |
|
104 |
|
maxes.convergence_diagram(ax) |
|
105 |
|
ax.sharex(ax1) |
|
106 |
|
|
95 |
107 |
def double_proxy_diagram(fig, sample_box, space, lim=1000): |
def double_proxy_diagram(fig, sample_box, space, lim=1000): |
96 |
108 |
ax1 = ax = fig.add_subplot(211) |
ax1 = ax = fig.add_subplot(211) |
97 |
109 |
ax.sample_box = sample_box |
ax.sample_box = sample_box |
File mplot/mgraph.py changed (mode: 100644) (index 54c067c..4a01931) |
... |
... |
def tri_estimation_fill(ax, df): |
22 |
22 |
#xkcd_cream = (255, 243, 154) # let's try xkcd: dark cream (#fff39a) |
#xkcd_cream = (255, 243, 154) # let's try xkcd: dark cream (#fff39a) |
23 |
23 |
cream = "#FFF39A" |
cream = "#FFF39A" |
24 |
24 |
grey = "#DDDDDD" |
grey = "#DDDDDD" |
25 |
|
colors = (red, cream, grey, green) |
|
|
25 |
|
|
26 |
26 |
o = df['outside'].to_numpy() |
o = df['outside'].to_numpy() |
27 |
27 |
s = df['success'].to_numpy() |
s = df['success'].to_numpy() |
28 |
28 |
f = df['failure'].to_numpy() |
f = df['failure'].to_numpy() |
29 |
29 |
m = df['mix'].to_numpy() |
m = df['mix'].to_numpy() |
30 |
|
labels = ("failure domain", "mixed domain",\ |
|
31 |
|
"outside domain", "success domain") |
|
32 |
|
return ax.stackplot(df.index, f, m, o, s, labels=labels, colors=colors) |
|
|
30 |
|
kwargs = {'colors': (red, cream, grey, green), |
|
31 |
|
'labels': ("failure domain", "mixed domain",\ |
|
32 |
|
"outside domain", "success domain")} |
|
33 |
|
if len(df.index) > 1000: |
|
34 |
|
kwargs['rasterized'] = True |
|
35 |
|
return ax.stackplot(df.index, f, m, o, s, **kwargs) |
33 |
36 |
|
|
34 |
37 |
|
|
35 |
38 |
#č sehnaní datarámu necháme uživateli |
#č sehnaní datarámu necháme uživateli |
|
... |
... |
def tri_estimation_plot(ax, df, pf_exact=None, pf_exact_method="$p_f$", |
88 |
91 |
#č blbost, ale uspořadal jsem tu prvky tak, |
#č blbost, ale uspořadal jsem tu prvky tak, |
89 |
92 |
#č aby se hezky kreslily v legendě |
#č aby se hezky kreslily v legendě |
90 |
93 |
|
|
|
94 |
|
if (len(df.index) > 1000) and ('rasterize' not in kwargs): |
|
95 |
|
kwargs['rasterized'] = True |
|
96 |
|
|
91 |
97 |
v = df['vertex_estimation'].to_numpy() |
v = df['vertex_estimation'].to_numpy() |
92 |
98 |
wv = df['weighted_vertex_estimation'].to_numpy() |
wv = df['weighted_vertex_estimation'].to_numpy() |
93 |
99 |
ax.plot(df.index, wv, '-r', label="weighted $p_f$ estimation", zorder=100500, **kwargs) |
ax.plot(df.index, wv, '-r', label="weighted $p_f$ estimation", zorder=100500, **kwargs) |