JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
jkqtpsinglecolumnsymbols.h
1/*
2 Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
3
4
5
6 This software is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License (LGPL) as published by
8 the Free Software Foundation, either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License (LGPL) for more details.
15
16 You should have received a copy of the GNU Lesser General Public License (LGPL)
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20
21#ifndef jkqtpgraphssinglecolumnsymbols_H_INCLUDED
22#define jkqtpgraphssinglecolumnsymbols_H_INCLUDED
23
24
25#include <QString>
26#include <QPainter>
27#include <QPair>
28#include "jkqtplotter/jkqtpgraphsbase.h"
29#include "jkqtplotter/jkqtpgraphsbasestylingmixins.h"
30
31
32
33/*! \brief plots a 1-column set of data-values with symbols onto a JKQtPlotter/JKQtBasePlotter. the data from the single column
34 is either interpreted as x- or y-values and the missing coordinate is taken from a fixed value position.
35 \ingroup jkqtplotter_linesymbolgraphs_scatter
36
37 The first coordinate of the data is taken from dataColumn i.e.
38 - the x-values if dataDirection==DataDirection::X
39 - the y-values if dataDirection==DataDirection::Y
40 .
41
42 The second coordinate is:
43 - if positionScatterStyle==NoScatter it is simply the value of position, e.g. <br>\image html JKQTPSingleColumnSymbolsGraph_NoScatter.png
44 - if positionScatterStyle==RugPlot is like a NoScatter-plot, but with lines instead of symbols (see <a href="https://en.wikipedia.org/wiki/Rug_plot">https://en.wikipedia.org/wiki/Rug_plot</a>) <br>\image html JKQTPSingleColumnSymbolsGraph_RugPlot.png
45 - if positionScatterStyle==RandomScatter it scatters around position in the range [position-width/2 ... position+width/2], e.g. <br>\image html JKQTPSingleColumnSymbolsGraph_RandomScatter.png
46 - if positionScatterStyle==BeeSwarmScatter it scatters around position with an algorithm that tries to avoid any overlay of the plot symbols (SLOW!), e.g. <br>\image html JKQTPSingleColumnSymbolsGraph_BeeSwarmScatter.png
47 .
48 All example images above have dataDirection==DataDirection::X !
49
50 \see \ref JKQTPlotterDistributionPlot, \ref JKQTPlotterViolinplotGraphs
51
52 */
54 Q_OBJECT
55 public:
56 /** \brief describes how data from dataColumn of a JKQTPSingleColumnSymbolsGraph positioned at position */
58 NoScatter, /*!< \brief missing coordinate is exactly position for every datapoint in dataColumn \image html JKQTPSingleColumnSymbolsGraph_NoScatter.png */
59 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 */
60 RandomScatter, /*!< \brief missing coordinate scatters around position (with distribution-width width ) \image html JKQTPSingleColumnSymbolsGraph_RandomScatter.png */
61 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 */
62 };
63
64 /** \brief class constructor */
67
68 /** \copydoc JKQTPPlotElement::getXMinMax() */
69 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
70 /** \copydoc JKQTPPlotElement::getYMinMax() */
71 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
72
73
74 /** \brief plots the graph to the plotter object specified as parent */
75 virtual void draw(JKQTPEnhancedPainter& painter) override;
76 /** \brief plots a key marker inside the specified rectangle \a rect */
77 virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) override;
78 /** \brief returns the color to be used for the key label */
79 virtual QColor getKeyLabelColor() const override;
80 /** \brief set symbol color and fill color at the same time */
81 void setColor(QColor col);
82
83 /** \copydoc position */
84 void setPosition(double __value);
85 /** \copydoc position */
86 double getPosition() const;
87
88 /** \copydoc width */
89 void setWidth(double __value);
90 /** \copydoc width */
91 double getWidth() const;
92
93
94
95 /** \copydoc positionScatterStyle */
97 /** \copydoc positionScatterStyle */
99
100
101
102 /** \copydoc seedValue */
103 void setSeedValue(unsigned int val);
104 /** \copydoc seedValue */
105 unsigned int getSeedValue() const;
106 protected:
107 /** \brief missing coordinate, i.e. if the data from \a dataColumn is interpreted as x-values, this is the y-position and vice versa (see DataDirection ) */
108 double position;
109 /** \brief width of data distribution around position for the missing coordinate (see positionScatterStyle and position) */
110 double width;
111 /** \brief how to distribute the datapoints from dataColumn at the location position */
113 /** \brief seed value for the pseudo-random number generator used for drawing.
114 *
115 * This seed is used instead of e.g. the system time to ensure that replotting results in the
116 * same plot every time. ou can set the seed using setSeedvalue() ) */
117 unsigned int seedValue;
118
119};
120
121
122
123
124#endif // jkqtpgraphssinglecolumnsymbols_H_INCLUDED
base class for 2D plotter classes (used by the plotter widget JKQTPlotter)
Definition jkqtpbaseplotter.h:394
this class extends the QPainter
Definition jkqtpenhancedpainter.h:33
This Mix-In class provides setter/getter methods, storage and other facilities for the graph symbols ...
Definition jkqtpgraphsbasestylingmixins.h:379
This virtual JKQTPGraph descendent may be used as base for all graphs that use at least one column of...
Definition jkqtpgraphsbase.h:875
plots a 1-column set of data-values with symbols onto a JKQtPlotter/JKQtBasePlotter....
Definition jkqtpsinglecolumnsymbols.h:53
JKQTPSingleColumnSymbolsGraph(JKQTPlotter *parent)
double getPosition() const
missing coordinate, i.e. if the data from dataColumn is interpreted as x-values, this is the y-positi...
void setSeedValue(unsigned int val)
seed value for the pseudo-random number generator used for drawing.
virtual QColor getKeyLabelColor() const override
returns the color to be used for the key label
double width
width of data distribution around position for the missing coordinate (see positionScatterStyle and p...
Definition jkqtpsinglecolumnsymbols.h:110
void setWidth(double __value)
width of data distribution around position for the missing coordinate (see positionScatterStyle and p...
unsigned int getSeedValue() const
seed value for the pseudo-random number generator used for drawing.
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
double position
missing coordinate, i.e. if the data from dataColumn is interpreted as x-values, this is the y-positi...
Definition jkqtpsinglecolumnsymbols.h:108
ScatterStyle
describes how data from dataColumn of a JKQTPSingleColumnSymbolsGraph positioned at position
Definition jkqtpsinglecolumnsymbols.h:57
@ BeeSwarmScatter
missing coordinate scatters around position and the algorithm tries to prevent overlay of two symbols...
Definition jkqtpsinglecolumnsymbols.h:61
@ RugPlot
like NoScatter but draws each data-point as a horzintal/vertical line, centered around position,...
Definition jkqtpsinglecolumnsymbols.h:59
@ RandomScatter
missing coordinate scatters around position (with distribution-width width )
Definition jkqtpsinglecolumnsymbols.h:60
@ NoScatter
missing coordinate is exactly position for every datapoint in dataColumn
Definition jkqtpsinglecolumnsymbols.h:58
void setColor(QColor col)
set symbol color and fill color at the same time
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
double getWidth() const
width of data distribution around position for the missing coordinate (see positionScatterStyle and p...
void setPosition(double __value)
missing coordinate, i.e. if the data from dataColumn is interpreted as x-values, this is the y-positi...
ScatterStyle getPositionScatterStyle() const
how to distribute the datapoints from dataColumn at the location position
void setPositionScatterStyle(ScatterStyle __value)
how to distribute the datapoints from dataColumn at the location position
JKQTPSingleColumnSymbolsGraph(JKQTBasePlotter *parent=nullptr)
class constructor
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
ScatterStyle positionScatterStyle
how to distribute the datapoints from dataColumn at the location position
Definition jkqtpsinglecolumnsymbols.h:112
unsigned int seedValue
seed value for the pseudo-random number generator used for drawing.
Definition jkqtpsinglecolumnsymbols.h:117
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
plotter widget for scientific plots (uses JKQTBasePlotter to do the actual drawing)
Definition jkqtplotter.h:364
#define JKQTPLOTTER_LIB_EXPORT
Definition jkqtplotter_imexport.h:89