Thx Jason, this looks exactly what I need. But I guess adding this to QCustomPlot library is beyond what I could do. I'm left with asking for it to be implemented by the author.
Cheers ! On Thu, 21 Jun 2018 at 17:11, Jason H <[email protected]> wrote: > You'll have to write code, but it's not that hard. > > Pens don't know about where they are on the painted surface. > Painters do know where they are drawing, and they use the pen, so the code > using the painter has to do it. > > QPainter painter > > double range = max-min; > > for (const auto &segment :segments) { > double y_hue=(((segment.y1+segment.y2)/2) - min) / range; > QColor color= QColor::fromHSFV( y_hue,1,1); > painter.setPen(color); > painter.drawLine(segment.x1, segment.y1, segment.x2, segment.2); > } > > or somehing like that. > > > *Sent:* Thursday, June 21, 2018 at 10:20 AM > *From:* "Massimiliano Maini" <[email protected]> > *To:* [email protected] > *Cc:* [email protected] > *Subject:* Re: [Interest] Plotting 2d line with color depending on value > (like colormap) > Thanks Uwe and Jason. > > At the moment I'm using a 3rd party library (http://www.qcustomplot.com/): > very handy but doesn't seem to support what I need. > I was wondering if I the feature could be easily added as it is easily > doable in Qt (as in "there's a special QPen to do this") or not. > Looks like the answer is NO. > > Regards, > > On Thu, 21 Jun 2018 at 15:42, Jason H <[email protected]> wrote: > >> It's a simple mapping of y value to "H" in a HSV space over the >> normalized range of values. >> >> To do it in a bitmap is easy, to do it as a line like you 'd want on a >> vector plot, i'd take the y midpoint value of the segment and use that for >> the pen color for the whole line, choosing a sensible number of points. >> >> >> >> >> >> *Sent:* Thursday, June 21, 2018 at 5:51 AM >> *From:* "Massimiliano Maini" <[email protected]> >> *To:* [email protected] >> *Subject:* [Interest] Plotting 2d line with color depending on value >> (like colormap) >> Hi all, >> >> I'd need to do something like this: https://imgur.com/MLAEuad >> >> I have a set of (x,y,z) data points and want to plot them on a usual 2d >> plot ( x and y values), but with the line color depending on the z values >> (colormap). >> >> How can this be achieved in Qt ? >> >> Max. >> >> >> _______________________________________________ Interest mailing list >> [email protected] >> http://lists.qt-project.org/mailman/listinfo/interest >> >
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
