From: Xavier C. <car...@gm...> - 2020-01-21 18:38:47
|
Hi, any comment on this ? I really can't find the reason lines seem to get off viewport box randomly, even after several tries refactoring this function ... any help would be appreciated ! On Thu, Jan 16, 2020 at 4:04 PM Xavier Cardil <car...@gm...> wrote: > Hi, I am trying to draw boxes following example 32 > <http://plplot.sourceforge.net/examples.php?demo=32&lbind=C++>. I > successfully implemented this on Python, but there is some weird problem > when trying to do it on C++: > > Sometimes, boxes are drawn correctly : > > > [image: 20200116_160142.png] > > But sometimes, ( seems random ) this happens : > > > [image: 20200116_155042.png] > > Is this something I am missing ? I can't figure out why is this happening? > > Below is my code, which is really simple. Thanks > > > plstream p; > > const auto hmax = max_element(begin(vec.high), end(vec.high)); > const auto lmin = min_element(begin(vec.low), end(vec.low)); > > vector<int> ivec(vecsize); > > generate(ivec.begin(), ivec.end(), [steps = 0]() mutable { return steps++; > }); > const char *device = "xwin"; > p.start(device, 1, 1); > p.ssub(0, 1); > p.env(0, vecsize, *lmin, *hmax, 0, 0); > > PLFLT px[5], py[5]; > PLFLT wx[5], wy[5]; > PLFLT spacing; > PLFLT xmid; > > spacing = .4; // in x axis units > > for (int i = 0; i < vecsize; i++) { > px[0] = ivec[i] + spacing / 2.; > py[0] = vec.open[i]; > px[1] = ivec[i] + spacing / 2.; > py[1] = vec.close[i]; > px[2] = ivec[i] + 1. - spacing / 2.; > py[2] = vec.close[i]; > px[3] = ivec[i] + 1. - spacing / 2.; > py[3] = vec.open[i]; > px[4] = ivec[i] + spacing / 2.; > py[4] = vec.open[i]; > > p.col0(1); > p.line(vecsize, px, py); > |