Save more CSV files when iteration-wise plotting is enabled. draft

Thu, 08 Dec 2022 14:10:07 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Thu, 08 Dec 2022 14:10:07 +0200
changeset 21
0771706f472f
parent 20
90f77ad9a98d

Save more CSV files when iteration-wise plotting is enabled.

This helps to generate TikZ illustrations for presentations.

src/plot.rs file | annotate | diff | comparison | revisions
--- a/src/plot.rs	Fri Dec 09 14:10:48 2022 +0200
+++ b/src/plot.rs	Thu Dec 08 14:10:07 2022 +0200
@@ -16,7 +16,7 @@
 use alg_tools::loc::Loc;
 use alg_tools::bisection_tree::Bounds;
 use alg_tools::maputil::map4;
-use alg_tools::tabledump::write_csv;
+use alg_tools::tabledump::{write_csv, TableDump};
 use crate::measures::*;
 
 /// Default RGB ramp from [`colorbrewer`].
@@ -78,6 +78,8 @@
         let s = μ.iter_masses().fold(F::ZERO, |m, α| m.add(α));
         let mut spike_scale = F::ONE;
 
+        μ.write_csv(format!("{filename}_mu.txt").into()).expect("CSV save error");
+
         let mut plotter = poloto::plot(
             "f", "x",
             format!("f(x); spike max={:.4}, n={}, ∑={:.4}", m, μ.len(), s)
@@ -88,16 +90,14 @@
                 [x0.as_(), ω.apply(&x).as_()]
             });
             plotter.line(ω_explanation.as_str(), graph_ω.clone());
-            // let csv_f = format!("{}.txt", filename);
-            // write_csv(graph_ω, csv_f).expect("CSV save error");
+            write_csv(graph_ω, format!("{filename}_omega.txt")).expect("CSV save error");
         }
 
         let graph_g = grid.into_iter().map(|x@Loc([x0]) : Loc<F, 1>| {
             [x0.as_(), g.apply(&x).as_()]
         });
         plotter.line(g_explanation.as_str(), graph_g.clone());
-        // let csv_f = format!("{}.txt", filename);
-        // write_csv(graph_g, csv_f).expect("CSV save error");
+        write_csv(graph_g, format!("{filename}_g.txt")).expect("CSV save error");
 
         bnd0.map(|bnd| {
             let upperb = bnd.upper().as_();
@@ -106,6 +106,9 @@
             let lower = [[start, lowerb], [end, lowerb]];
             spike_scale *= bnd.upper();
 
+            write_csv([[lowerb, upperb]].into_iter(),
+                       format!("{filename}_bounds.txt")).expect("CSV save error");
+
             plotter.line("upper bound", upper)
                    .line("lower bound", lower)
                    .ymarker(lowerb)

mercurial