ToFuProject / tofu

Project for an open-source python library for synthetic diagnostics and tomography for Fusion devices
https://tofuproject.github.io/tofu/index.html
MIT License
69 stars 11 forks source link

More flexible `plot_diagnostic_coverage()` #931

Closed dvezinet closed 1 month ago

dvezinet commented 1 month ago

Implement the following + possible others to allow easily plotting on custom figures:

$ git diff
diff --git a/tofu/data/_class8_plot_coverage.py b/tofu/data/_class8_plot_coverage.py
index f93181e0..ea366e37 100644
--- a/tofu/data/_class8_plot_coverage.py
+++ b/tofu/data/_class8_plot_coverage.py
@@ -394,6 +394,9 @@ def _plot(
         cax = fig.add_subplot(gs[0, 15])
         dax = {'span': ax0, 'ndet': ax1}

+    else:
+        fig = list(dax.values())[0].figure
+
     # ---------------
     # plot ndet
     # ---------------
@@ -412,7 +415,10 @@ def _plot(
             vmax=vmax,
         )

-        plt.colorbar(im, cax=cax)
+        if dax.get('cax') is not None:
+            plt.colorbar(im, cax=dax['cax'])
+        else:
+            plt.colorbar(im)

     # ---------------
     # plot spans