Skip to content

Commit 94f0afa

Browse files
committed
convergence and residuum plot titles
1 parent 9e3c739 commit 94f0afa

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

examples/config/plotter.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,18 @@
5757
# - arrow_scale: relative arrow length (with respect to the voxel size)
5858
#
5959
# - "convergence": plot the convergence of the iterative matrix solver (matplotlib)
60+
# - title: title located at the top of the plot (null for hiding)
6061
# - color_active: color of the plot for the active power
6162
# - color_reactive: color of the plot for the reactive power
6263
# - marker: plot marker size
6364
# - width: line line width
6465
#
6566
# - "convergence": plot the solver residuum histogram (matplotlib)
66-
# - n_bins: number of bins
67-
# - tol_bins: relative tolerance for the bin boundaries
67+
# - title: title located at the top of the plot (null for hiding)
6868
# - bar_color: fill color of the bins
6969
# - edge_color: "edge color of the bins
70+
# - tol_bins: relative tolerance for the bin boundaries
71+
# - n_bins: number of bins for the residuum histogram
7072
#
7173
# Thomas Guillod - Dartmouth College
7274
# Mozilla Public License Version 2.0
@@ -246,6 +248,7 @@
246248
"data_window": !include cfg_data_window.yaml
247249
"data_options": !include cfg_data_matplotlib.yaml
248250
"data_plot":
251+
"title": "Convergence"
249252
"color_active": "red"
250253
"color_reactive": "blue"
251254
"marker": 8.0
@@ -256,7 +259,8 @@
256259
"data_window": !include cfg_data_window.yaml
257260
"data_options": !include cfg_data_matplotlib.yaml
258261
"data_plot":
259-
"n_bins": 10
260-
"tol_bins": 0.05
262+
"title": "Residuum"
261263
"bar_color": "blue"
262264
"edge_color": "black"
265+
"tol_bins": 0.05
266+
"n_bins": 10

pypeec/data/schema_list_plotter.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@
3535
"data_plot_convergence": &data_plot_convergence
3636
"type": "object"
3737
"required":
38+
- "title"
3839
- "color_active"
3940
- "color_reactive"
4041
- "marker"
4142
- "width"
4243
properties:
44+
"title":
45+
"type":
46+
- "null"
47+
- "string"
48+
"minLength": 1
4349
"color_active":
4450
"type": "string"
4551
"minLength": 1
@@ -57,11 +63,17 @@
5763
"data_plot_residuum": &data_plot_residuum
5864
"type": "object"
5965
"required":
66+
- "title"
6067
- "bar_color"
6168
- "edge_color"
6269
- "tol_bins"
6370
- "n_bins"
6471
properties:
72+
"title":
73+
"type":
74+
- "null"
75+
- "string"
76+
"minLength": 1
6577
"bar_color":
6678
"type": "string"
6779
"minLength": 1

pypeec/lib_plot/manage_matplotlib.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def _get_plot_residuum(fig, res, data_plot):
2020
"""
2121

2222
# extract the data
23+
title = data_plot["title"]
2324
n_bins = data_plot["n_bins"]
2425
tol_bins = data_plot["tol_bins"]
2526
bar_color = data_plot["bar_color"]
@@ -28,10 +29,6 @@ def _get_plot_residuum(fig, res, data_plot):
2829
# activate the figure
2930
plt.figure(fig)
3031

31-
# get rms
32-
n_dof = len(res)
33-
res_rms = np.sqrt(np.mean(np.abs(res) ** 2))
34-
3532
# get absolute value
3633
res_abs = np.abs(res)
3734

@@ -56,7 +53,8 @@ def _get_plot_residuum(fig, res, data_plot):
5653
plt.grid()
5754
plt.xlabel("residuum (a.u.)")
5855
plt.ylabel("counts (a.u.)")
59-
plt.title("Residuum / n_dof = %d / res_rms = %.2e" % (n_dof, res_rms))
56+
if title is not None:
57+
plt.title(title)
6058

6159

6260
def _get_plot_convergence(fig, conv, data_plot):
@@ -65,6 +63,7 @@ def _get_plot_convergence(fig, conv, data_plot):
6563
"""
6664

6765
# extract the data
66+
title = data_plot["title"]
6867
color_active = data_plot["color_active"]
6968
color_reactive = data_plot["color_reactive"]
7069
marker = data_plot["marker"]
@@ -102,7 +101,8 @@ def _get_plot_convergence(fig, conv, data_plot):
102101
plt.legend()
103102
plt.xlabel("iterations (#)")
104103
plt.ylabel("convergence (a.u.)")
105-
plt.title(f"Convergence: S = {power_final:.2e} VA")
104+
if title is not None:
105+
plt.title(title)
106106

107107

108108
def get_plot_plotter(fig, res, conv, layout, data_plot, data_options):

0 commit comments

Comments
 (0)