Skip to content

Commit 41dd019

Browse files
Calculate even bar widths in plots.
1 parent d98e897 commit 41dd019

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/plot.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -913,25 +913,23 @@ namespace ecolab
913913
}
914914
};
915915

916+
// compute minimum gap between successive points to determine bar width
917+
double w=iflogx(maxx)-iflogx(minx);
918+
for (size_t j=1; j<x[i].size(); ++j)
919+
w=std::min(w, iflogx(x[i][j])-iflogx(x[i][j-1]));
920+
w*=ls.barWidth;
921+
916922
size_t j=0;
917923
if (inBounds(iflogx(x[i][j]), y[i][j], side))
918924
{
919-
auto w = ls.barWidth*(x[i].size()>1? abs(iflogx(x[i][1]) - iflogx(x[i][0])): iflogx(maxx)-iflogx(minx));
920925
auto xx=x[i].size()>1? iflogx(x[i][0])-0.5*w: iflogx(minx);
921926
shadowShowBox(xx,xfy(y[i][0]),w);
922927
}
923928
for (++j; j<x[i].size()-1; ++j)
924929
if (inBounds(iflogx(x[i][j]), y[i][j], side))
925-
{
926-
auto w=ls.barWidth*min(abs(iflogx(x[i][j]) - iflogx(x[i][j-1])),
927-
abs(iflogx(x[i][j+1])-iflogx(x[i][j])));
928-
shadowShowBox(iflogx(x[i][j])-0.5*w, xfy(y[i][j]), w);
929-
}
930-
if (x[i].size()>1 && inBounds(iflogx(x[i][j]), y[i][j], side))
931-
{
932-
auto w=ls.barWidth*abs(iflogx(x[i][j]) - iflogx(x[i][j-1]));
933930
shadowShowBox(iflogx(x[i][j])-0.5*w, xfy(y[i][j]), w);
934-
}
931+
if (x[i].size()>1 && inBounds(iflogx(x[i][j]), y[i][j], side))
932+
shadowShowBox(iflogx(x[i][j])-0.5*w, xfy(y[i][j]), w);
935933
}
936934
default: break;
937935
}

0 commit comments

Comments
 (0)