Commit b9450e55 authored by Lambert Theisen's avatar Lambert Theisen
Browse files

Change plot behavior

- Always export PDF
- Is good for test coverage
parent f24e4e76
Pipeline #170095 passed with stages
in 9 minutes and 20 seconds
......@@ -30,7 +30,7 @@ def main():
mesh_names = params["meshes"]
convergence_study = params["convergence_study"]["enable"]
plot = params["convergence_study"]["plot"]
show_plot = params["convergence_study"]["plot"]
data = []
......@@ -67,8 +67,7 @@ def main():
if p == len(mesh_names)-1: # after last mesh
postp = Postprocessor(data, params["case_name"])
postp.write_errors()
if plot:
postp.plot_errors()
postp.plot_errors(show_plot)
solver = None
gc.collect()
......
......@@ -15,20 +15,24 @@ class Postprocessor:
self.data = data
self.output_folder = output_folder
def plot_errors(self):
def plot_errors(self, show_popup):
"""
Use ``matplotlib`` to plot all errors in a figure.
Exporting PDFs with
Exporting PDFs with:
.. code-block:: python
# Write PDF without access to backend, i.e. use PDF backend
import matplotlib
matplotlib.use('pdf')
import matplotlib.pyplot as plt # pylint: disable=C0413
"""
filename = "convergence_plot_" + self.output_folder + ".pdf"
if not show_popup:
plt.switch_backend('agg')
plt.figure(num=None, figsize=(16, 9), dpi=100)
data = self.data
......@@ -94,7 +98,8 @@ class Postprocessor:
plt.tight_layout()
plt.savefig(self.output_folder + "/" + filename, dpi=150)
plt.show()
if show_popup:
plt.show()
def write_errors(self):
"Writes errors to csv file"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment