File mart.py changed (mode: 100644) (index 2192c77..5bc331e) |
... |
... |
import matplotlib.patches as mpatches |
12 |
12 |
|
|
13 |
13 |
from . import misc |
from . import misc |
14 |
14 |
|
|
15 |
|
def get_simplices_colors(sb, simplices): #simplices = bx.tri.simplices |
|
16 |
|
s = '#a7ffb5' #'xkcd:light seafoam green' #a7ffb5 |
|
17 |
|
f = '#fdc1c5' #'xkcd: pale rose' # (#fdc1c5) |
|
18 |
|
m = '#FFF39A' #'xkcd: dark cream' # (255, 243, 154, 255) |
|
19 |
|
|
|
20 |
|
in_failure = np.isin(simplices, sb.failure_points) |
|
21 |
|
has_failure = in_failure.any(axis=1) |
|
22 |
|
all_failure = in_failure.all(axis=1) |
|
23 |
|
return np.where(has_failure, np.where(all_failure, f, m), s) |
|
24 |
|
|
|
|
15 |
|
#č Tahlensta blbost je použita funkcí tripcolor() |
|
16 |
|
#č Je třeba jú překopat na Triangulation třidu, |
|
17 |
|
#č která get_events má jako svůj method. |
25 |
18 |
def get_events(sb, simplices): #simplices = bx.tri.simplices |
def get_events(sb, simplices): #simplices = bx.tri.simplices |
26 |
19 |
""" |
""" |
27 |
20 |
Metoda musí simplexům přiřazovat jev |
Metoda musí simplexům přiřazovat jev |
|
... |
... |
def center_spines(ax): |
345 |
338 |
ax.plot(1, 0, ">k", transform=ax.get_yaxis_transform(), clip_on=False) |
ax.plot(1, 0, ">k", transform=ax.get_yaxis_transform(), clip_on=False) |
346 |
339 |
ax.plot(0, 1, "^k", transform=ax.get_xaxis_transform(), clip_on=False) |
ax.plot(0, 1, "^k", transform=ax.get_xaxis_transform(), clip_on=False) |
347 |
340 |
|
|
348 |
|
|
|
|
341 |
|
#č před použitím bude třeba skutečně naimportovat ticker |
349 |
342 |
def fix_locator(ax, loc): |
def fix_locator(ax, loc): |
350 |
343 |
loc_x = mpl.ticker.FixedLocator(loc) |
loc_x = mpl.ticker.FixedLocator(loc) |
351 |
344 |
ax.xaxis.set_major_locator(loc_x) |
ax.xaxis.set_major_locator(loc_x) |
File maxes.py added (mode: 100644) (index 0000000..9443370) |
|
1 |
|
#!/usr/bin/env python |
|
2 |
|
# coding: utf-8 |
|
3 |
|
|
|
4 |
|
# Axes level functions (for Matplotlib) |
|
5 |
|
|
|
6 |
|
#č Založme nový modul pro funkce (procedury), |
|
7 |
|
#č které sice stejně jako mart pracují na urovni axes, |
|
8 |
|
#č ale na rozdil od atomických funkcí mart modulu |
|
9 |
|
#č udělaj z prazdných os hotový obrazek. |
|
10 |
|
#č mplot.show2D() může použivat tuhle nabídku obrázků. |
|
11 |
|
|
|
12 |
|
from . import mart |
|
13 |
|
|
|
14 |
|
# it is mostly for qt_plot, it offers availiable options to user |
|
15 |
|
__all__ = ['base_drawing', 'candidates_drawing'] |
|
16 |
|
|
|
17 |
|
|
|
18 |
|
def base_drawing(ax): |
|
19 |
|
mart.setup(ax) |
|
20 |
|
mart.curly(ax) |
|
21 |
|
try: |
|
22 |
|
mart.triplot(ax, color="grey", linewidth=0.4) |
|
23 |
|
except: |
|
24 |
|
pass |
|
25 |
|
mart.plot_boundaries(ax, linewidth=0.7) |
|
26 |
|
mart.scatter_points(ax) |
|
27 |
|
|
|
28 |
|
|
|
29 |
|
def candidates_drawing(ax): |
|
30 |
|
try: |
|
31 |
|
mart.triplot(ax, color="grey", linewidth=0.4) |
|
32 |
|
except: |
|
33 |
|
pass |
|
34 |
|
mart.plot_boundaries(ax, linewidth=0.7) |
|
35 |
|
|
|
36 |
|
#č ax.scatter posílá parameter cmap Collections třídě. |
|
37 |
|
#č Třída mimo jiného dědí cm.ScalarMappable, |
|
38 |
|
#č která inicializaci deleguje funkci cm.get_cmap() ve (svém) modulu cm. |
|
39 |
|
# cmap='viridis_r' #cmap='plasma', |
|
40 |
|
mart.scatter_candidates(ax, s=5, marker='.', cmap='plasma_r',\ |
|
41 |
|
alpha=None, linewidths=None, edgecolors=None, plotnonfinite=False) |
|
42 |
|
mart.plot_the_best_candidate(ax, "^", color='#3D0D5B') |
|
43 |
|
|
|
44 |
|
mart.scatter_points(ax) |
|
45 |
|
|
|
46 |
|
|
File mplot.py changed (mode: 100644) (index 917a8cb..ce5171f) |
... |
... |
import matplotlib |
10 |
10 |
import matplotlib.pyplot as plt |
import matplotlib.pyplot as plt |
11 |
11 |
matplotlib.rcParams['mathtext.fontset'] = 'cm' # Computer Modern (TeX) |
matplotlib.rcParams['mathtext.fontset'] = 'cm' # Computer Modern (TeX) |
12 |
12 |
matplotlib.rcParams['font.family'] = 'STIXGeneral' |
matplotlib.rcParams['font.family'] = 'STIXGeneral' |
|
13 |
|
matplotlib.rcParams['savefig.dpi'] = 300 |
13 |
14 |
|
|
14 |
|
from . import mart |
|
|
15 |
|
from . import maxes |
15 |
16 |
|
|
|
17 |
|
def show2D(sample_box, space='R', drawing=None): |
|
18 |
|
fig = plt.figure() |
|
19 |
|
ax = fig.add_subplot(111) |
|
20 |
|
ax.space = space |
|
21 |
|
ax.sample_box = sample_box |
|
22 |
|
|
|
23 |
|
if drawing is None: |
|
24 |
|
maxes.base_drawing(ax) |
|
25 |
|
else: |
|
26 |
|
getattr(maxes, drawing)(ax) |
|
27 |
|
# specially for qt_plot. It already runs event loop |
|
28 |
|
return fig.show() |
|
29 |
|
|
|
30 |
|
|
16 |
31 |
|
|
17 |
32 |
def subplot3D(sample_box, ax3d, space='R'): |
def subplot3D(sample_box, ax3d, space='R'): |
18 |
33 |
Fails = getattr(sample_box.failure_samples, space) |
Fails = getattr(sample_box.failure_samples, space) |
File qt_plot.py changed (mode: 100644) (index fabb236..04a3015) |
... |
... |
from pyqtgraph import console |
10 |
10 |
import numpy as np |
import numpy as np |
11 |
11 |
import pandas as pd # required for estimation graph |
import pandas as pd # required for estimation graph |
12 |
12 |
|
|
13 |
|
#ё я сдаюсь. |
|
|
13 |
|
#č vzdávám se. |
14 |
14 |
#č quadpy tak se stavá povinnou závislostí |
#č quadpy tak se stavá povinnou závislostí |
15 |
15 |
#č potrebuju pro HullEstimation widget |
#č potrebuju pro HullEstimation widget |
16 |
16 |
import quadpy |
import quadpy |
|
... |
... |
class QtGuiPlot2D(QtGui.QMainWindow): |
97 |
97 |
self.ncircles = 5 |
self.ncircles = 5 |
98 |
98 |
self.redraw_called.connect(self.central_widget.clear) |
self.redraw_called.connect(self.central_widget.clear) |
99 |
99 |
|
|
100 |
|
|
|
|
100 |
|
# should be INHERITED by gl_plot |
|
101 |
|
def initialize_matplotlib_menu(self): |
|
102 |
|
try: # entire optional functionality |
|
103 |
|
from .mplot import show2D |
|
104 |
|
from . import maxes |
|
105 |
|
self.matplotlib_menu = self.bar.addMenu("Matplotlib") |
|
106 |
|
self.matplotlib_actions = [] |
|
107 |
|
for drawing in maxes.__all__: |
|
108 |
|
mpl_action = QtGui.QAction(drawing, self) |
|
109 |
|
# do not really understand what I am doing :( |
|
110 |
|
# try to show_mpl remember its actual drawing string |
|
111 |
|
show_mpl = self._get_mpl_function(show2D, drawing) |
|
112 |
|
mpl_action.triggered.connect(show_mpl) |
|
113 |
|
self.matplotlib_menu.addAction(mpl_action) |
|
114 |
|
# prevent GC from wiping out both Qt object and our function |
|
115 |
|
self.matplotlib_actions.append((mpl_action, show_mpl)) |
|
116 |
|
|
|
117 |
|
except ImportError as e: |
|
118 |
|
msg = "Matplotlib related features are unavailiable" |
|
119 |
|
print(self.__class__.__name__ + ":", msg, repr(e)) |
|
120 |
|
|
|
121 |
|
def _get_mpl_function(self, show, drawing): |
|
122 |
|
return lambda: show(self.sample_box, space=self.space, drawing=drawing) |
|
123 |
|
|
101 |
124 |
# INHERITED by gl_plot |
# INHERITED by gl_plot |
102 |
125 |
# intended as a common setup function |
# intended as a common setup function |
103 |
126 |
def setup(self): |
def setup(self): |
|
... |
... |
class QtGuiPlot2D(QtGui.QMainWindow): |
110 |
133 |
self.batch_run_action.triggered.connect(self.batch_run) |
self.batch_run_action.triggered.connect(self.batch_run) |
111 |
134 |
self.graph_menu.addAction(self.batch_run_action) |
self.graph_menu.addAction(self.batch_run_action) |
112 |
135 |
|
|
|
136 |
|
# optional feature |
|
137 |
|
self.initialize_matplotlib_menu() |
113 |
138 |
|
|
114 |
139 |
### Create some widgets to be placed inside |
### Create some widgets to be placed inside |
115 |
140 |
self.combo_space = pg.ComboBox(items=self.spaces, default=self.space) |
self.combo_space = pg.ComboBox(items=self.spaces, default=self.space) |