diff --git a/pub/src/dualplot.cpp b/pub/src/dualplot.cpp index e5182d2c78757387b89cb616490f6c4be7cfd699..a52e8a804696de7b75d69476f0ebb499c72dc7fb 100644 --- a/pub/src/dualplot.cpp +++ b/pub/src/dualplot.cpp @@ -179,7 +179,7 @@ void CPlot::plotFrame( string xlabel, string ylabel ) //! Plot one spectrum. -void CPlot::addSpec( bool as_line, int style_no, +void CPlot::addSpec( bool as_line, bool new_style, int style_no, const vector<double>& xp, const vector<double>& yp, const vector<double>& dyp, const vector<double>& z, @@ -229,22 +229,26 @@ void CPlot::addSpec( bool as_line, int style_no, throw "no points in frame: " + info; // Postscript copy: - snprintf( outlin, mLin, "\n%3u [", ++ps_snum ); - ps_accu.push_back( outlin ); - for (uint i=0; i<z.size(); i++){ - snprintf( outlin, mLin, " %12g", z[i]); + if ( new_style ) { + snprintf( outlin, mLin, "\n%3u [", ++ps_snum ); + ps_accu.push_back( outlin ); + for (uint i=0; i<z.size(); i++){ + snprintf( outlin, mLin, " %12g", z[i]); + ps_accu.push_back( outlin ); + } + snprintf( outlin, mLin, " ] zValues\n" ); + ps_accu.push_back( outlin ); + if ( as_line ) + snprintf( outlin, mLin, "%2d cstyle", 1 ); + else + snprintf( outlin, mLin, "%2d pstyle", style_no+1 ); + ps_accu.push_back( outlin ); + snprintf( outlin, mLin-2, " %% (%s -> %s)", xco.c_str(), yco.c_str() ); + strncat( outlin, "\n", mLin ); ps_accu.push_back( outlin ); + } else { + ps_accu.push_back( "\n" ); } - snprintf( outlin, mLin, " ] zValues\n" ); - ps_accu.push_back( outlin ); - if ( as_line ) - snprintf( outlin, mLin, "%2d cstyle", 1 ); - else - snprintf( outlin, mLin, "%2d pstyle", style_no+1 ); - ps_accu.push_back( outlin ); - snprintf( outlin, mLin-2, " %% (%s -> %s)", xco.c_str(), yco.c_str() ); - strncat( outlin, "\n", mLin ); - ps_accu.push_back( outlin ); for (uint i=0; i<np; i++) { snprintf( outlin, mLin, "%6.3f %6.3f %6.3f t%c %% %13.7g wx %13.7g wy\n", diff --git a/pub/src/dualplot.h b/pub/src/dualplot.h index c15a06d1a07f7c6fa8df616edd5a7f1f8476f6e4..0afb1f725aebfc30686a81904f42738d678bc8e5 100644 --- a/pub/src/dualplot.h +++ b/pub/src/dualplot.h @@ -17,7 +17,7 @@ class CPlot { void gp_write( string ); void clearFrame(); void plotFrame( string xlabel, string ylabel ); - void addSpec( bool as_line, int style_no, + void addSpec( bool as_line, bool new_style, int style_no, const vector<double>& xp, const vector<double>& yp, const vector<double>& dyp, const vector<double>& z, diff --git a/pub/src/plot.cpp b/pub/src/plot.cpp index f126adcaaef7dc2ca421e838848af2b72593d10e..6fa3be7539b644f876be998422b3fa009b98c058 100644 --- a/pub/src/plot.cpp +++ b/pub/src/plot.cpp @@ -196,7 +196,7 @@ void NPlot::Plot( class CPlot *plot, bool add ) continue; } else { plot->addSpec( - false, pstyle++, xp, yp, dyp, f->V[j]->z, + false, true, pstyle++, xp, yp, dyp, f->V[j]->z, f->xco.str(), f->yco.str(), "data file " + strg(k) + " spectrum "+strg(j) ); } @@ -228,7 +228,7 @@ void NPlot::Plot( class CPlot *plot, bool add ) cout << "curve k="<<strg(k)<<", j="<<strg(j)<<" is empty\n"; return; } - plot->addSpec( true, cstyle++, xo, yo, novec, f->V[j]->z, + plot->addSpec( true, true, cstyle++, xo, yo, novec, f->V[j]->z, f->xco.str(), f->yco.str(), "curve file "+strg(k)+" spectrum "+strg(j) ); @@ -245,7 +245,7 @@ void NPlot::Plot( class CPlot *plot, bool add ) yp.push_back( yc[i] ); } } - plot->addSpec( true, cstyle++, xp, yp, novec, f->V[j]->z, + plot->addSpec( true, true, cstyle++, xp, yp, novec, f->V[j]->z, f->xco.str(), f->yco.str(), "curve file "+strg(k)+" spectrum "+strg(j) ); @@ -376,6 +376,7 @@ void NPlot::Plot( class CPlot *plot, bool add ) // divide into segments and plot: vector<double> xa, ya; + bool first_seg = true; for ( uint i=0; i<xn.size(); ++i ) { if ( plot->Y.contains(yn[i]) ) { xa.push_back( xn[i] ); @@ -385,11 +386,12 @@ void NPlot::Plot( class CPlot *plot, bool add ) if ( xa.size() ){ //cout << "DEB segment -> " << xa.size() << "\n"; plot->addSpec( - true, cstyle, xa, ya, + true, first_seg, cstyle, xa, ya, novec, f->V[j]->z, f->xco.str(), f->yco.str(), "curve file "+strg(k)+ " spectrum "+strg(j) ); xa.clear(); ya.clear(); + first_seg = false; } } }