Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
highperformancecoder committed Mar 15, 2024
2 parents 8d3ebac + d288a6e commit bb76199
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/plot.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ namespace ecolab

bool inBounds(float x, float y, Side side) const {
return std::isfinite(x) && std::isfinite(y) && x>=minx && x<=maxx && (!logy || y>0) &&
((side==left && y>=miny && y<=maxy)
(((side==left||side==marker) && y>=miny && y<=maxy)
|| (side==right && y>=miny1 && y<=maxy1));
}

bool displayRHSscale() const {return !penSide.empty() && miny1<maxy1;}
bool displayLHSscale() const {return miny<maxy;}
string axisLabel(double x, double scale, bool percent=false) const;

bool onlyMarkers() const; ///< return true if the only data is marker data
public:
Plot(): palette(paletteSz), msg(NULL), nxTicks(30), nyTicks(30), fontScale(1),
offx(0), offy(0), logx(false), logy(false),
Expand Down
18 changes: 13 additions & 5 deletions src/plot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,21 @@ namespace ecolab
penSide[pen]=side;
}

bool Plot::onlyMarkers() const
{
bool r=true;
for (size_t i=0; i<x.size(); ++i)
r &= x[i].empty() || (i<penSide.size() && penSide[i]==marker);
return r;
}

void Plot::setMinMax()
{
assert(x.size()==y.size());
msg=NULL;

// calculate min/max
if (x.empty())
if (onlyMarkers())
{
minx=logx? 0.1: -1;
maxx=1;
Expand All @@ -322,12 +329,12 @@ namespace ecolab
assert(x[i].size()==y[i].size());
for (size_t j=0; j<x[i].size(); ++j)
{
if (finite(x[i][j]))
if (isfinite(x[i][j]))
{
if (x[i][j]<minx) minx=x[i][j];
if (x[i][j]>maxx) maxx=x[i][j];
}
if (finite(y[i][j]))
if (isfinite(y[i][j]))
{
if (i<penSide.size() && penSide[i]==right)
{
Expand Down Expand Up @@ -918,8 +925,9 @@ namespace ecolab
else if (isfinite(xfyyij))
cairo_move_to(cairo, iflogx(x[i][j]), xfyyij);
}

if (leadingMarker && isfinite(xfy(y[i].back())))

// markers don't need the leading marker.
if (leadingMarker && (i>=penSide.size() || penSide[i]!=marker) && isfinite(xfy(y[i].back())))
cairo_rectangle
(cairo, iflogx(x[i].back()), xfy(y[i].back()),
0.01*dx, 0.01*dy*sy);
Expand Down

0 comments on commit bb76199

Please sign in to comment.