From c8395f2ada5dd23ca3f7ed4b376343163572aaa1 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 16 Jun 2019 13:27:40 +0200 Subject: [PATCH] JKQTPSingleColumnSymbolsGraph: added Rug-Plot --- .../JKQTPSingleColumnSymbolsGraph_RugPlot.png | Bin 0 -> 4171 bytes .../jkqtpgraphssinglecolumnsymbols.cpp | 38 ++++++++++++++++-- .../jkqtpgraphssinglecolumnsymbols.h | 1 + 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 doc/images/JKQTPSingleColumnSymbolsGraph_RugPlot.png diff --git a/doc/images/JKQTPSingleColumnSymbolsGraph_RugPlot.png b/doc/images/JKQTPSingleColumnSymbolsGraph_RugPlot.png new file mode 100644 index 0000000000000000000000000000000000000000..3434c6f588224e4765bd74ff59f4891f336167fc GIT binary patch literal 4171 zcmV-R5VY@!P)f6Xi@@54ZTQ_E-Enz5K6$1 z03tR-RB%L5k){YTDBysjLy@r}iiH7DvFijGMAUI`6dRUFWUU$Bym{}eS9UO(Z2>7`&z9wUXbV-Il z#&6`Y8GKGQ04S2&F6MJnWNa;Ck|;8QE#r9r;7G||@X{|>%+C|c55>;RS}qbKr-&IQ zTvLXPlM{>K&(BTgi^a?^4mXV>;xX8n8Ce|RasXz}{8imI52H3ZN4bf ze_i~WlJ|C&UW9+{8AKoW!}eExnGFE2re(F+`iE_46#!l90Z_aBhs|Iw0E)7{bq;-T z9=d#9QpDmcXDh4R++0fmpKB>E=%LdZt9g z$j;($`3&Zthxi`{{&gM}5&R^+h%b~yM9Zd3AWW9ETgVfL1(`yIK=_}U_z%PWq}jQa ziQ4!P(3V&Nr6C$XejWfQDiI(Fdt@un?|lo#M+5oIi_w{wo%_#%{(V=tO#a9gB!7-$ zM?^BX5>d|Vn*3S!?g~$*UQipUP zL&zMmg;!4Do9IA%up=Rh?=qPj=x&RGBx1dpI68aT- z2O}^EromdU5o`ssU{5#*j)WJ%$?!5bA1;Eoz?EiTr=n?cd`V|I)p<|3O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U;jT=>b_?cp23_g8Aq`VwW6uZUa$7(&dZ!6(VooW}7 z@kM5i!5Dq~2;993WI~S7SvkYThnX_i8 zf79>n?Mg`WAIEX7*<}o~9mSMPNQ^D*?6Qy?ge7Z7n8^t;IXO9gn~*XQiZ$RAcP6;M zgghe&f(CkY){Zcf6Xa`BOG^vFa!qP7o*^REEonfhsi{Hnq)FXAuUwG?K?5QrLC}B* zNf0z3Sv#MRtesvYYbOXHMzVH3BUwAWNY+jeLW~GW5Huh{5(EuM*3M@nYo`~<+6h94 zk*uB1NY+j-lC=|r5F_yJ^O#L9SNth3DG^5x`n@nP1huLX~v zwO%yHQ%c?7QORE8usl6IvAnXQTl^pELq~dHlAE+mGf9%CqstV?TG(8ablv4<>kQl@5(OXoOAT( zSf8Oom5uZRf4C;LKYKPYK2M*j-`09M+Y1&02H4v^d>D%dPtHwc9G*g(O1s^=Rea+} zO-K$WC1mZ~CiXJMEy$_%wXg!x$#@mU=5~D>#s9I*t4(}4ZL`jpcAhounA`Jh6jnR_ zj{odNeEDB$6RoPUzm0XSwRRnJ^F9$Yis+jzO(jzmAALIqrSf0bZ`*tNoHq!o!|C&l{Yjrm~jt^J dRandomScatter{position-width/2.0, position+width/2.0}; const double symSize=parent->pt2px(painter, getSymbolSize()); + QPen p=painter.pen(); + p.setColor(getSymbolColor()); + p.setWidthF(qMax(JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, getSymbolLineWidth()))); + p.setStyle(Qt::SolidLine); + p.setCapStyle(Qt::FlatCap); QVector plotSymbols; // collects symbol locations e.g. for BeeSwarmScatter-plots @@ -154,7 +159,13 @@ void JKQTPSingleColumnSymbolsGraph::draw(JKQTPEnhancedPainter &painter) } plotSymbols.append(QPointF(x,y)); if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { - plotStyledSymbol(parent, painter, x, y); + if (positionScatterStyle!=RugPlot) { + plotStyledSymbol(parent, painter, x, y); + } else { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setPen(p); + painter.drawLine(QLineF(x, y-symSize,x,y+symSize)); + } addHitTestData(xv, yv,iii, datastore); } } @@ -180,8 +191,13 @@ void JKQTPSingleColumnSymbolsGraph::draw(JKQTPEnhancedPainter &painter) } plotSymbols.append(QPointF(x,y)); if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) { - plotSymbols.append(QPointF(x,y)); - plotStyledSymbol(parent, painter, x, y); + if (positionScatterStyle!=RugPlot) { + plotStyledSymbol(parent, painter, x, y); + } else { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + painter.setPen(p); + painter.drawLine(QLineF(x-symSize, y,x+symSize,y)); + } addHitTestData(xv, yv,iii, datastore); } } @@ -206,7 +222,21 @@ void JKQTPSingleColumnSymbolsGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=getSymbolPen(painter, parent); painter.setPen(p); - JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), symbolSize, symbolWidth, getKeyLabelColor(), getSymbolFillColor()); + if (positionScatterStyle!=RugPlot) { + JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), symbolSize, symbolWidth, getKeyLabelColor(), getSymbolFillColor()); + } else { + painter.translate(rect.center()); + if (dataDirection==DataDirection::X) { + painter.rotate(90); + } + painter.drawLine(QLineF(-rect.width()/4.0, rect.height()*(-0.4), rect.width()/4.0, rect.height()*(-0.4))); + painter.drawLine(QLineF(-rect.width()/4.0, rect.height()*(-0.2), rect.width()/4.0, rect.height()*(-0.2))); + painter.drawLine(QLineF(-rect.width()/4.0, rect.height()*0.0, rect.width()/4.0, rect.height()*0.0)); + painter.drawLine(QLineF(-rect.width()/4.0, rect.height()*0.05, rect.width()/4.0, rect.height()*0.05)); + painter.drawLine(QLineF(-rect.width()/4.0, rect.height()*0.15, rect.width()/4.0, rect.height()*0.15)); + painter.drawLine(QLineF(-rect.width()/4.0, rect.height()*0.3, rect.width()/4.0, rect.height()*0.3)); + painter.drawLine(QLineF(-rect.width()/4.0, rect.height()*0.45, rect.width()/4.0, rect.height()*0.45)); + } } diff --git a/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h b/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h index 389b78a751..11855908e7 100644 --- a/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h +++ b/lib/jkqtplotter/jkqtpgraphssinglecolumnsymbols.h @@ -57,6 +57,7 @@ class JKQTP_LIB_EXPORT JKQTPSingleColumnSymbolsGraph: public JKQTPSingleColumnGr NoScatter, /*!< \brief missing coordinate is exactly position for every datapoint in dataColumn \image html JKQTPSingleColumnSymbolsGraph_NoScatter.png */ RandomScatter, /*!< \brief missing coordinate scatters around position (with distribution-width width ) \image html JKQTPSingleColumnSymbolsGraph_RandomScatter.png */ BeeSwarmScatter, /*!< \brief missing coordinate scatters around position and the algorithm tries to prevent overlay of two symbols ("bee swarm plot", see e.g. https://www.r-statistics.com/2011/03/beeswarm-boxplot-and-plotting-it-with-r/). Note that this algorithm can be rather slow!!! \image html JKQTPSingleColumnSymbolsGraph_BeeSwarmScatter.png */ + RugPlot, /*!< \brief like NoScatter but draws each data-point as a horzintal/vertical line, centered around position, not as a symbol ("rug plot", see e.g. https://en.wikipedia.org/wiki/Rug_plot). \image html JKQTPSingleColumnSymbolsGraph_RugPlot.png */ }; /** \brief class constructor */