From d15d4e2e7d59373da190456091d9a090c698bde5 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (l)" <j.wuttke@fz-juelich.de>
Date: Wed, 12 Jul 2017 22:09:35 +0200
Subject: [PATCH] no more than one empty line between 2D blocks; begin&end tags

---
 pub/lib/plot.cpp        | 11 ++++++++---
 pub/plot/ps_plotter.cpp |  3 ++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/pub/lib/plot.cpp b/pub/lib/plot.cpp
index 4068199f..bd91b785 100644
--- a/pub/lib/plot.cpp
+++ b/pub/lib/plot.cpp
@@ -568,14 +568,19 @@ namespace {
         for (size_t j=0; j<m; ++j) {
             const CSpec* s = fd->VS(j);
             vector<double> xlim = triv::histogram_limits(s->x);
-            for (size_t i=0; i<s->size(); ++i)
+            bool block_empty = false;
+            for (size_t i=0; i<s->size(); ++i) {
                 if (  (plot->Y.force || plot->Y.contains(s->y[i]))
                     && plot->X.contains(xlim[i]) && plot->X.contains(xlim[i+1])
-                    && plot->Z.contains(zlim[j]) && plot->Z.contains(zlim[j+1]))
+                    && plot->Z.contains(zlim[j]) && plot->Z.contains(zlim[j+1])) {
+                    block_empty = false;
                     plot->ps_line(
                         str(format("%13.7g wx %13.7g wx  %13.7g wy %13.7g wy  %13.7g wH t2d")
                             % xlim[i] % xlim[i+1] % zlim[j] % zlim[j+1] % s->y[i] ) );
-            plot->ps_line("");
+                }
+            }
+            if (!block_empty)
+                plot->ps_line("");
         }
         plot->close_frame2D(fd->xco.str_ps(), fd->ZCo[0].str_ps(), fd->yco.str_ps());
         // doclines
diff --git a/pub/plot/ps_plotter.cpp b/pub/plot/ps_plotter.cpp
index 6f15c97d..caf204fa 100644
--- a/pub/plot/ps_plotter.cpp
+++ b/pub/plot/ps_plotter.cpp
@@ -70,13 +70,14 @@ void CPS_Plotter::start_frame2D(
     ps_accu += ps_coord(X);
     ps_accu += ps_coord(Z);
     ps_accu += ps_coord(Y);
-    ps_accu += "\n";
+    ps_accu += "\n%% 2D image begin\n";
 }
 
 void CPS_Plotter::close_frame2D(
     const CAxis& _X, const CAxis& _Z, const CAxis& _Y,
     const std::string& xlabel, const std::string& zlabel, const std::string& ylabel)
 {
+    ps_accu += "%% 2D image end\n\n";
     ps_accu += "/linsetTic {white 1 setline} def\n";
     ps_accu += "/linsetTac {white 1.3 setline} def\n\n";
 
-- 
GitLab