mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 17:41:39 +08:00
JKQTPSingleColumnSymbolsGraph: added Rug-Plot
This commit is contained in:
parent
f96e262371
commit
c8395f2ada
BIN
doc/images/JKQTPSingleColumnSymbolsGraph_RugPlot.png
Normal file
BIN
doc/images/JKQTPSingleColumnSymbolsGraph_RugPlot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
@ -119,6 +119,11 @@ void JKQTPSingleColumnSymbolsGraph::draw(JKQTPEnhancedPainter &painter)
|
||||
std::uniform_real_distribution<> 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<QPointF> 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)) {
|
||||
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));
|
||||
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);
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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. <a href="https://www.r-statistics.com/2011/03/beeswarm-boxplot-and-plotting-it-with-r/">https://www.r-statistics.com/2011/03/beeswarm-boxplot-and-plotting-it-with-r/</a>). 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. <a href="https://en.wikipedia.org/wiki/Rug_plot">https://en.wikipedia.org/wiki/Rug_plot</a>). \image html JKQTPSingleColumnSymbolsGraph_RugPlot.png */
|
||||
};
|
||||
|
||||
/** \brief class constructor */
|
||||
|
Loading…
Reference in New Issue
Block a user