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
jkqtpviolinplot.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#ifndef jkqtpgraphsviolinplot_H
21#define jkqtpgraphsviolinplot_H
22
23
24#include <QString>
25#include <QPainter>
26#include <QPair>
27#include "jkqtplotter/jkqtptools.h"
28#include "jkqtplotter/jkqtplotter_imexport.h"
29#include "jkqtplotter/jkqtpimagetools.h"
30#include "jkqtplotter/jkqtpgraphsbase.h"
31#include "jkqtplotter/graphs/jkqtpviolinplotstylingmixins.h"
32#include "jkqtplotter/jkqtpgraphsbasestylingmixins.h"
33
34
35
36/** \brief This implements a single vertical <a href="https://en.wikipedia.org/wiki/Violin_plot">Violin Plot</a> as a "geometric element"
37 * \ingroup jkqtplotter_statgraphs
38 * \ingroup jkqtplotter_statgraphs
39 *
40 * Represents a violin plot in one of the following styles:
41 *
42 * \image html JKQTPGraphViolinplot_SmoothViolin.png
43 *
44 * \image html JKQTPGraphViolinplot_StepViolin.png
45 *
46 * \image html JKQTPGraphViolinplot_BoxViolin.png
47 *
48 * \see JKQTPViolinplotVerticalElement, JKQTPViolinplotHorizontalElement
49 *
50 */
52 Q_OBJECT
53public:
54 /** \brief class constructor */
56
57 /** \brief returns the color to be used for the key label */
58 virtual QColor getKeyLabelColor() const override;
59
60
61 /** \copydoc pos */
62 void setPos(double __value);
63 /** \copydoc pos */
64 double getPos() const;
65 /** \copydoc median */
66 double getMedian() const;
67 /** \copydoc mean */
68 double getMean() const;
69 /** \copydoc min */
70 double getMin() const;
71 /** \copydoc max */
72 double getMax() const;
73
74
75 /** \copydoc drawMean */
76 bool getDrawMean() const;
77 /** \copydoc drawMedian */
78 bool getDrawMedian() const;
79 /** \copydoc drawMinMax */
80 bool getDrawMinMax() const;
81
82
83 /** \copydoc violinPositionColumn */
85
86
87 /** \copydoc violinFrequencyColumn */
89public Q_SLOTS:
90 /** \brief set the color of the graph (colors all elements, based on the given color \a c ) */
91 virtual void setColor(QColor c);
92 /** \copydoc violinFrequencyColumn */
93 void setViolinFrequencyColumn(int __value);
94 /** \copydoc violinFrequencyColumn */
95 void setViolinFrequencyColumn(size_t __value);
96 /** \copydoc violinPositionColumn */
97 void setViolinPositionColumn(int __value);
98 /** \copydoc violinPositionColumn */
99 void setViolinPositionColumn(size_t __value);
100 /** \copydoc drawMinMax */
101 void setDrawMinMax(bool __value);
102 /** \copydoc drawMedian */
103 void setDrawMedian(bool __value);
104 /** \copydoc drawMean */
105 void setDrawMean(bool __value);
106 /** \copydoc max */
107 void setMax(double __value);
108 /** \copydoc min */
109 void setMin(double __value);
110 /** \copydoc mean */
111 void setMean(double __value);
112 /** \copydoc median */
113 void setMedian(double __value);
114protected:
115
116 /** \brief the position of the boxplot on the "other" axis */
117 double pos;
118 /** \brief the median value to be used for the boxplot */
119 double median;
120 /** \brief the mean value to be used for the boxplot */
121 double mean;
122 /** \brief indicates whether to draw the mean */
124 /** \brief indicates whether to draw the median */
126 /** \brief indicates whether to draw the percentiles */
128 /** \brief the minimum value to be used for the boxplot */
129 double min;
130 /** \brief the maximum value to be used for the boxplot */
131 double max;
132 /** \brief column with data for the violin outline: category values (along min-max-axis) */
134 /** \brief column with data for the violin outline: frequency values (perpendicular to min-max-axis) */
136};
137
138
139/*! \brief This implements a single vertical <a href="https://en.wikipedia.org/wiki/Violin_plot">Violin Plot</a> as a "geometric element"
140 \ingroup jkqtplotter_statgraphs
141 \ingroup jkqtplotter_statgraphs
142
143 Draws a vertical violin plot in one of the following styles:
144
145 \image html JKQTPGraphViolinplot_SmoothViolin.png
146
147 \image html JKQTPGraphViolinplot_StepViolin.png
148
149 \image html JKQTPGraphViolinplot_BoxViolin.png
150
151
152 This graph/plot element represents a single such plot. Its center is positioned at an x-coordinate provided by setPos().
153 The width of the full plot (left+right!) is given by JKQTPGraphViolinplotStyleMixin::setViolinWidthAbsolute().
154
155 The data is represented partly by single values (e.g. setMedian(), setMin(), ...) and partly by the two columns set with
156 setViolinPositionColumn() and setViolinFrequencyColumn(). The latter two represent a density estimate (or histogram) of the
157 distribution represented by this plot, which is evaluated at the y-positions from setViolinPositionColumn(). For each such
158 y-position a (not necessarily normalized) frequency is given by the values in setViolinFrequencyColumn().
159
160
161 \image html JKQTPViolinplotHorizontalElement_elements.png
162
163 \see \ref JKQTPlotterViolinplotGraphs
164
165 */
167 Q_OBJECT
168 public:
169 /** \brief class constructor */
171 /** \brief class constructor */
173
174 /** \brief plots the graph to the plotter object specified as parent */
175 virtual void draw(JKQTPEnhancedPainter& painter) override;
176 /** \brief plots a key marker inside the specified rectangle \a rect */
177 virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) override;
178
179
180
181 /** \copydoc JKQTPPlotElement::getXMinMax() */
182 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
183 /** \copydoc JKQTPPlotElement::getYMinMax() */
184 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
185
186
187};
188
189
190/*! \brief This implements a single horizontal <a href="https://en.wikipedia.org/wiki/Violin_plot">Violin Plot</a> as a "geometric element"
191 \ingroup jkqtplotter_statgraphs
192 \ingroup jkqtplotter_statgraphs
193
194 Draws a horizontal violin plot in one of the following styles:
195
196 \image html JKQTPGraphViolinplot_HSmoothViolin.png
197
198 \image html JKQTPGraphViolinplot_HStepViolin.png
199
200 \image html JKQTPGraphViolinplot_HBoxViolin.png
201
202 This graph/plot element represents a single such plot. Its center is positioned at an y-coordinate provided by setPos().
203 The width of the full plot (top+bottom!) is given by JKQTPGraphViolinplotStyleMixin::setViolinWidthAbsolute().
204
205 The data is represented partly by single values (e.g. setMedian(), setMin(), ...) and partly by the two columns set with
206 setViolinPositionColumn() and setViolinFrequencyColumn(). The latter two represent a density estimate (or histogram) of the
207 distribution represented by this plot, which is evaluated at the x-positions from setViolinPositionColumn(). For each such
208 x-position a (not necessarily normalized) frequency is given by the values in setViolinFrequencyColumn().
209
210 \image html JKQTPViolinplotHorizontalElement_elements.png
211
212
213 \see \ref JKQTPlotterViolinplotGraphs
214
215 */
217 Q_OBJECT
218 public:
219 /** \brief class constructor */
221 /** \brief class constructor */
223
224 /** \brief plots the graph to the plotter object specified as parent */
225 virtual void draw(JKQTPEnhancedPainter& painter) override;
226 /** \brief plots a key marker inside the specified rectangle \a rect */
227 virtual void drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) override;
228
229
230 /** \copydoc JKQTPPlotElement::getXMinMax() */
231 virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
232 /** \copydoc JKQTPPlotElement::getYMinMax() */
233 virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
234};
235
236
237
238#endif // jkqtpgraphsviolinplot_H
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
Styling Mix-In for Violinplots.
Definition jkqtpviolinplotstylingmixins.h:43
this virtual base class of every element, which is part of a JKQTPlotter plot and may appear in its k...
Definition jkqtpgraphsbase.h:62
This implements a single vertical Violin Plot as a "geometric element".
Definition jkqtpviolinplot.h:51
void setDrawMedian(bool __value)
indicates whether to draw the median
double getMedian() const
the median value to be used for the boxplot
int getViolinPositionColumn() const
column with data for the violin outline: category values (along min-max-axis)
bool drawMedian
indicates whether to draw the median
Definition jkqtpviolinplot.h:125
double max
the maximum value to be used for the boxplot
Definition jkqtpviolinplot.h:131
double median
the median value to be used for the boxplot
Definition jkqtpviolinplot.h:119
void setDrawMinMax(bool __value)
indicates whether to draw the percentiles
double getMax() const
the maximum value to be used for the boxplot
int violinFrequencyColumn
column with data for the violin outline: frequency values (perpendicular to min-max-axis)
Definition jkqtpviolinplot.h:135
int getViolinFrequencyColumn() const
column with data for the violin outline: frequency values (perpendicular to min-max-axis)
double min
the minimum value to be used for the boxplot
Definition jkqtpviolinplot.h:129
virtual QColor getKeyLabelColor() const override
returns the color to be used for the key label
void setViolinFrequencyColumn(size_t __value)
column with data for the violin outline: frequency values (perpendicular to min-max-axis)
void setMax(double __value)
the maximum value to be used for the boxplot
bool getDrawMean() const
indicates whether to draw the mean
void setPos(double __value)
the position of the boxplot on the "other" axis
bool drawMean
indicates whether to draw the mean
Definition jkqtpviolinplot.h:123
double pos
the position of the boxplot on the "other" axis
Definition jkqtpviolinplot.h:117
bool getDrawMedian() const
indicates whether to draw the median
bool drawMinMax
indicates whether to draw the percentiles
Definition jkqtpviolinplot.h:127
double mean
the mean value to be used for the boxplot
Definition jkqtpviolinplot.h:121
void setViolinPositionColumn(int __value)
column with data for the violin outline: category values (along min-max-axis)
double getMean() const
the mean value to be used for the boxplot
int violinPositionColumn
column with data for the violin outline: category values (along min-max-axis)
Definition jkqtpviolinplot.h:133
bool getDrawMinMax() const
indicates whether to draw the percentiles
void setMin(double __value)
the minimum value to be used for the boxplot
virtual void setColor(QColor c)
set the color of the graph (colors all elements, based on the given color c )
double getMin() const
the minimum value to be used for the boxplot
void setDrawMean(bool __value)
indicates whether to draw the mean
void setMedian(double __value)
the median value to be used for the boxplot
void setMean(double __value)
the mean value to be used for the boxplot
JKQTPViolinplotElementBase(JKQTBasePlotter *parent=nullptr)
class constructor
void setViolinFrequencyColumn(int __value)
column with data for the violin outline: frequency values (perpendicular to min-max-axis)
double getPos() const
the position of the boxplot on the "other" axis
void setViolinPositionColumn(size_t __value)
column with data for the violin outline: category values (along min-max-axis)
This implements a single horizontal Violin Plot as a "geometric element".
Definition jkqtpviolinplot.h:216
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
JKQTPViolinplotHorizontalElement(JKQTBasePlotter *parent=nullptr)
class constructor
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
JKQTPViolinplotHorizontalElement(JKQTPlotter *parent)
class constructor
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
This implements a single vertical Violin Plot as a "geometric element".
Definition jkqtpviolinplot.h:166
virtual bool getYMinMax(double &miny, double &maxy, double &smallestGreaterZero) override
get the maximum and minimum y-value of the graph
virtual bool getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) override
get the maximum and minimum x-value of the graph
JKQTPViolinplotVerticalElement(JKQTPlotter *parent)
class constructor
JKQTPViolinplotVerticalElement(JKQTBasePlotter *parent=nullptr)
class constructor
virtual void drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect) override
plots a key marker inside the specified rectangle rect
virtual void draw(JKQTPEnhancedPainter &painter) override
plots the graph to the plotter object specified as parent
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