JKQTPlotter:
- FIXED plot-size calculation for filled graphs - added example for filled graphs with error indicators
@ -126,6 +126,7 @@ if(JKQtPlotter_BUILD_EXAMPLES)
|
|||||||
simpletest
|
simpletest
|
||||||
barchart/barchart,barchart_hor
|
barchart/barchart,barchart_hor
|
||||||
barchart_twocolor/barchart_twocolor,barchart_twocolor_hor
|
barchart_twocolor/barchart_twocolor,barchart_twocolor_hor
|
||||||
|
barchart_errorbars/barchart_errorbars,barchart_errorbars_hor
|
||||||
wiggleplots/wiggleplot_x,wiggleplot_y
|
wiggleplots/wiggleplot_x,wiggleplot_y
|
||||||
advplotstyling/advancedlineandfillstyling
|
advplotstyling/advancedlineandfillstyling
|
||||||
boxplot
|
boxplot
|
||||||
@ -136,6 +137,7 @@ if(JKQtPlotter_BUILD_EXAMPLES)
|
|||||||
distributionplot/test_distributionplot
|
distributionplot/test_distributionplot
|
||||||
evalcurve
|
evalcurve
|
||||||
filledgraphs/filledgraphs,filledgraphs_y
|
filledgraphs/filledgraphs,filledgraphs_y
|
||||||
|
filledgraphs_errors/filledgraphs_errors,filledgraphs_errors_y
|
||||||
functionplot/functionplot,functionplot_fy
|
functionplot/functionplot,functionplot_fy
|
||||||
styledboxplot/test_styledboxplot
|
styledboxplot/test_styledboxplot
|
||||||
multiplot/multiplot,multiplot_controlwindow
|
multiplot/multiplot,multiplot_controlwindow
|
||||||
@ -174,9 +176,11 @@ if(JKQtPlotter_BUILD_EXAMPLES)
|
|||||||
simpletest/JKQTPXYLineGraph/--smallscreenshotplot
|
simpletest/JKQTPXYLineGraph/--smallscreenshotplot
|
||||||
barchart/JKQTPBarVerticalGraph,JKQTPBarHorizontalGraph/--smallscreenshotplot
|
barchart/JKQTPBarVerticalGraph,JKQTPBarHorizontalGraph/--smallscreenshotplot
|
||||||
barchart_twocolor/JKQTPBarVerticalGraphTwoColorFilling,JKQTPBarHorizontalGraphTwoColorFilling/--smallscreenshotplot
|
barchart_twocolor/JKQTPBarVerticalGraphTwoColorFilling,JKQTPBarHorizontalGraphTwoColorFilling/--smallscreenshotplot
|
||||||
|
barchart_errorbars/JKQTPBarVerticalErrorGraph,JKQTPBarHorizontalErrorGraph/--smallscreenshotplot
|
||||||
wiggleplots/JKQTPFilledCurveXGraph_wiggle,JKQTPFilledCurveYGraph_wiggle
|
wiggleplots/JKQTPFilledCurveXGraph_wiggle,JKQTPFilledCurveYGraph_wiggle
|
||||||
contourplot/JKQTPColumnContourPlot/--smallscreenshotplot
|
contourplot/JKQTPColumnContourPlot/--smallscreenshotplot
|
||||||
filledgraphs/JKQTPFilledCurveXGraph,JKQTPFilledCurveYGraph/--smallscreenshotplot
|
filledgraphs/JKQTPFilledCurveXGraph,JKQTPFilledCurveYGraph/--smallscreenshotplot
|
||||||
|
filledgraphs_errors/JKQTPFilledCurveXErrorGraph,JKQTPFilledCurveYErrorGraph/--smallscreenshotplot
|
||||||
evalcurve/JKQTPXYFunctionLineGraph/--smallscreenshotplot
|
evalcurve/JKQTPXYFunctionLineGraph/--smallscreenshotplot
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ This group assembles graphs that show their data with symbols and optionally wit
|
|||||||
<td>\image html filledgraphs_small.png
|
<td>\image html filledgraphs_small.png
|
||||||
<td> JKQTPFilledCurveXGraph, JKQTPFilledCurveYGraph
|
<td> JKQTPFilledCurveXGraph, JKQTPFilledCurveYGraph
|
||||||
<tr>
|
<tr>
|
||||||
<td>\image html plot_filledcurvexerrorplots_small.png
|
<td>\image html JKQTPFilledCurveXErrorGraph_small.png
|
||||||
<td> JKQTPFilledCurveXErrorGraph, JKQTPFilledCurveYErrorGraph
|
<td> JKQTPFilledCurveXErrorGraph, JKQTPFilledCurveYErrorGraph
|
||||||
<tr>
|
<tr>
|
||||||
<td>\image html JKQTPfilledVerticalRangeGraph_WithLines_small.png
|
<td>\image html JKQTPfilledVerticalRangeGraph_WithLines_small.png
|
||||||
|
@ -25,6 +25,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
|||||||
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/80">#80: Bug with multiple inheritance with Q_GDAGET with CLANG</a>, thanks to <a href="https://github.com/igormironchik">user:igormironchik</a>, caused by <a href="https://bugreports.qt.io/browse/QTBUG-104874">QTBUG-104874</a></li>
|
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/80">#80: Bug with multiple inheritance with Q_GDAGET with CLANG</a>, thanks to <a href="https://github.com/igormironchik">user:igormironchik</a>, caused by <a href="https://bugreports.qt.io/browse/QTBUG-104874">QTBUG-104874</a></li>
|
||||||
<li>FIXED: styling was not properly applied to coordinate axes of colorbars outside the plot</li>
|
<li>FIXED: styling was not properly applied to coordinate axes of colorbars outside the plot</li>
|
||||||
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/73">#73: Symbol thickness differs in actual plot and legend</a>, thanks to <a href="https://github.com/sim186">user:sim186</a></li>
|
<li>FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/73">#73: Symbol thickness differs in actual plot and legend</a>, thanks to <a href="https://github.com/sim186">user:sim186</a></li>
|
||||||
|
<li>FIXED plot-size calculation for filled graphs</li>
|
||||||
<li>REORGANIZED: separated line-graphs from jkqtpscatter.h/.cpp into jkqtplines.h/.cpp</li>
|
<li>REORGANIZED: separated line-graphs from jkqtpscatter.h/.cpp into jkqtplines.h/.cpp</li>
|
||||||
<li>IMPROVED: QT6-compatibility by removing deprecated warnings</li>
|
<li>IMPROVED: QT6-compatibility by removing deprecated warnings</li>
|
||||||
<li>NEW: JKQTPFilledCurveXGraph and JKQTPFilledCurveYGraph can now plot wiggle plots with different fill styles above and below the baseline (feature request <a href="https://github.com/jkriege2/JKQtPlotter/issues/68">#68 Wiggle Plots</a> from <a href="https://github.com/xichaoqiang">user:xichaoqiang</a> </li>
|
<li>NEW: JKQTPFilledCurveXGraph and JKQTPFilledCurveYGraph can now plot wiggle plots with different fill styles above and below the baseline (feature request <a href="https://github.com/jkriege2/JKQtPlotter/issues/68">#68 Wiggle Plots</a> from <a href="https://github.com/xichaoqiang">user:xichaoqiang</a> </li>
|
||||||
|
BIN
doc/images/JKQTPFilledCurveXErrorGraph.png
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
doc/images/JKQTPFilledCurveXErrorGraph_small.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
doc/images/JKQTPFilledCurveYErrorGraph.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
doc/images/JKQTPFilledCurveYErrorGraph_small.png
Normal file
After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 23 KiB |
34
examples/filledgraphs_errors/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
set(EXAMPLE_NAME filledgraphs_errors)
|
||||||
|
set(EXENAME jkqtptest_${EXAMPLE_NAME})
|
||||||
|
|
||||||
|
message( STATUS ".. Building Example ${EXAMPLE_NAME}" )
|
||||||
|
|
||||||
|
|
||||||
|
# Set up source files
|
||||||
|
set(SOURCES filledgraphs_errors.cpp )
|
||||||
|
set(HEADERS )
|
||||||
|
set(RESOURCES )
|
||||||
|
set(UIS )
|
||||||
|
|
||||||
|
add_executable(${EXENAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} ${UIS})
|
||||||
|
target_link_libraries(${EXENAME} JKQTPExampleToolsLib)
|
||||||
|
target_include_directories(${EXENAME} PRIVATE ../../lib)
|
||||||
|
if(JKQtPlotter_BUILD_STATIC_LIBS)
|
||||||
|
target_link_libraries(${EXENAME} JKQTPlotterLib)
|
||||||
|
elseif(JKQtPlotter_BUILD_SHARED_LIBS)
|
||||||
|
target_link_libraries(${EXENAME} JKQTPlotterSharedLib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# precomiled headers to speed up compilation
|
||||||
|
if (JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
||||||
|
target_precompile_headers(${EXENAME} REUSE_FROM jkqtptest_simpletest)
|
||||||
|
endif (JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
||||||
|
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
install(TARGETS ${EXENAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
|
#Installation of Qt DLLs on Windows
|
||||||
|
jkqtplotter_deployqt(${EXENAME})
|
44
examples/filledgraphs_errors/README.md
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# Example (JKQTPlotter): Filled Graphs with Error Indicators {#JKQTPlotterFilledGraphsErrorBars}
|
||||||
|
This project (see [`filledgraphs_errors`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/filledgraphs_errors) shows how to draw filled graphs with different styles of error indicators.
|
||||||
|
|
||||||
|
The source code of the main application is (see [`filledgraphs_errors.cpp`](https://github.com/jkriege2/JKQtPlotter/tree/master/examples/filledgraphs_errors/filledgraphs_errors.cpp):
|
||||||
|
```.cpp
|
||||||
|
// 1. create a plotter window and get a pointer to the internal datastore (for convenience)
|
||||||
|
JKQTPlotter plot;
|
||||||
|
JKQTPDatastore* ds=plot.getDatastore();
|
||||||
|
|
||||||
|
// 2. now we create two columns for key and value
|
||||||
|
size_t columnK=ds->addLinearColumn(10, 0, 2.0*JKQTPSTATISTICS_PI,"k");
|
||||||
|
size_t columnV=ds->addColumnCalculatedFromColumn(columnK, &cos, "v");
|
||||||
|
|
||||||
|
// 3. create graph in the plot, which plots the dataset:
|
||||||
|
JKQTPBarGraphBase* graph=new JKQTPBarVerticalGraph(&plot);
|
||||||
|
graph->setKeyColumn(columnK);
|
||||||
|
graph->setValueColumn(columnV);
|
||||||
|
// set TwoColor fill Mode
|
||||||
|
graph->setFillMode(JKQTPBarGraphBase::FillMode::TwoColorFilling);
|
||||||
|
graph->setFillColor(QColor("green"));
|
||||||
|
graph->fillStyleBelow().setFillColor(QColor("red"));
|
||||||
|
plot.addGraph(graph);
|
||||||
|
|
||||||
|
// 4 autoscale the plot so the graph is contained
|
||||||
|
plot.zoomToFit();
|
||||||
|
|
||||||
|
// 5. show plotter and make it a decent size
|
||||||
|
plot.setWindowTitle(title);
|
||||||
|
plot.show();
|
||||||
|
plot.resize(400,400);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
The result looks like this:
|
||||||
|
|
||||||
|
![filledgraphs_errors](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/filledgraphs_errors.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
In order to draw horizontal error bars, you have to use `JKQTPBarHorizontalGraph` instead of `JKQTPBarVerticalGraph`:
|
||||||
|
|
||||||
|
![filledgraphs_errors_hor](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/filledgraphs_errors_hor.png)
|
||||||
|
|
||||||
|
|
87
examples/filledgraphs_errors/filledgraphs_errors.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/** \example filledgraphs_errors.cpp
|
||||||
|
* Shows how to draw filled graphs with error indicators in a JKQTPlotter
|
||||||
|
*
|
||||||
|
* \ref JKQTPlotterFilledGraphsErrorBars
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "jkqtpexampleapplication.h"
|
||||||
|
#include <QApplication>
|
||||||
|
#include "jkqtplotter/jkqtplotter.h"
|
||||||
|
#include "jkqtplotter/graphs/jkqtpscatter.h"
|
||||||
|
#include "jkqtplotter/graphs/jkqtpfilledcurve.h"
|
||||||
|
#include "jkqtpexampleapplication.h"
|
||||||
|
#include "jkqtcommon/jkqtpmathtools.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class TCHART>
|
||||||
|
void doExample(JKQTPlotter& plot, const QString& title)
|
||||||
|
{
|
||||||
|
// 1. create a plotter window and get a pointer to the internal datastore (for convenience)
|
||||||
|
JKQTPDatastore* ds=plot.getDatastore();
|
||||||
|
|
||||||
|
// 2. now we create three columns for key and value
|
||||||
|
size_t columnK=ds->addLinearColumn(9, 0.1*JKQTPSTATISTICS_PI, 1.0*JKQTPSTATISTICS_PI,"k");
|
||||||
|
size_t columnK2=ds->addLinearColumn(9, 1.1*JKQTPSTATISTICS_PI, 2.0*JKQTPSTATISTICS_PI,"k2");
|
||||||
|
size_t columnK3=ds->addLinearColumn(9, 2.1*JKQTPSTATISTICS_PI, 3.0*JKQTPSTATISTICS_PI,"k2");
|
||||||
|
size_t columnV=ds->addColumnCalculatedFromColumn(columnK, &sin, "v");
|
||||||
|
size_t columnV2=ds->addColumnCalculatedFromColumn(columnK2, [](double x) { return -sin(x); }, "v2");
|
||||||
|
size_t columnV3=ds->addColumnCalculatedFromColumn(columnK3, &sin, "v3");
|
||||||
|
size_t columnE=ds->addColumnCalculatedFromColumn(columnV, [](double x) { return 0.2*x; }, "error");
|
||||||
|
size_t columnE2=ds->addColumnCalculatedFromColumn(columnV2, [](double x) { return 0.2*x; }, "error");
|
||||||
|
size_t columnE3=ds->addColumnCalculatedFromColumn(columnV3, [](double x) { return 0.2*x; }, "error");
|
||||||
|
|
||||||
|
// 3. create a graph in the plot, which plots the dataset with symmetric:
|
||||||
|
TCHART* graph1=new TCHART(&plot);
|
||||||
|
graph1->setKeyColumn(columnK);
|
||||||
|
graph1->setValueColumn(columnV);
|
||||||
|
graph1->setValueErrorColumn(columnE);
|
||||||
|
// set error indicator style
|
||||||
|
graph1->setValueErrorStyle(JKQTPErrorBars);
|
||||||
|
graph1->setTitle(QObject::tr("JKQTPErrorBars"));
|
||||||
|
plot.addGraph(graph1);
|
||||||
|
|
||||||
|
// 4. create a second graph in the plot, which plots the second dataset with outer error bars only:
|
||||||
|
TCHART* graph2=new TCHART(&plot);
|
||||||
|
graph2->setKeyColumn(columnK2);
|
||||||
|
graph2->setValueColumn(columnV2);
|
||||||
|
graph2->setValueErrorColumn(columnE2);
|
||||||
|
// set error indicator style
|
||||||
|
graph2->setValueErrorStyle(JKQTPErrorPolygons);
|
||||||
|
graph2->setTitle(QObject::tr("JKQTPErrorPolygons"));
|
||||||
|
plot.addGraph(graph2);
|
||||||
|
|
||||||
|
// 5. create a third graph in the plot, which plots the second dataset with outer error bars only:
|
||||||
|
TCHART* graph3=new TCHART(&plot);
|
||||||
|
graph3->setKeyColumn(columnK3);
|
||||||
|
graph3->setValueColumn(columnV3);
|
||||||
|
graph3->setValueErrorColumn(columnE3);
|
||||||
|
// set error indicator style
|
||||||
|
graph3->setValueErrorStyle(JKQTPErrorLines);
|
||||||
|
graph3->setTitle(QObject::tr("JKQTPErrorLines"));
|
||||||
|
plot.addGraph(graph3);
|
||||||
|
|
||||||
|
|
||||||
|
// 6 autoscale the plot so the graph is contained
|
||||||
|
plot.zoomToFit();
|
||||||
|
|
||||||
|
// 7. show plotter and make it a decent size
|
||||||
|
plot.getPlotter()->setKeyPosition(JKQTPKeyInsideBottomLeft);
|
||||||
|
plot.setWindowTitle(title);
|
||||||
|
plot.show();
|
||||||
|
plot.resize(400,400);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
JKQTPAppSettingController highDPIController(argc,argv);
|
||||||
|
JKQTPExampleApplication app(argc, argv);
|
||||||
|
|
||||||
|
|
||||||
|
JKQTPlotter plotV, plotH;
|
||||||
|
doExample<JKQTPFilledCurveXErrorGraph>(plotV, "1: JKQTPFilledCurveXErrorGraph");
|
||||||
|
doExample<JKQTPFilledCurveYErrorGraph>(plotH, "2: JKQTPFilledCurveYErrorGraph");
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
@ -91,6 +91,7 @@ JKQTPFilledCurveGraphBase::FillMode JKQTPFilledCurveGraphBase::getFillMode() con
|
|||||||
return m_fillMode;
|
return m_fillMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JKQTPFilledCurveGraphBase::setColor(QColor c)
|
void JKQTPFilledCurveGraphBase::setColor(QColor c)
|
||||||
{
|
{
|
||||||
setLineColor(c);
|
setLineColor(c);
|
||||||
@ -222,6 +223,17 @@ void JKQTPFilledCurveXGraph::draw(JKQTPEnhancedPainter& painter) {
|
|||||||
drawErrorsAfter(painter);
|
drawErrorsAfter(painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JKQTPFilledCurveXGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
|
||||||
|
{
|
||||||
|
bool res=JKQTPXYGraph::getYMinMax(miny, maxy, smallestGreaterZero);
|
||||||
|
if (getBaseline()>0 && getBaseline()<smallestGreaterZero) {
|
||||||
|
smallestGreaterZero=getBaseline();
|
||||||
|
}
|
||||||
|
miny=qMin(miny,getBaseline());
|
||||||
|
maxy=qMax(maxy,getBaseline());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
JKQTPFilledCurveYGraph::JKQTPFilledCurveYGraph(JKQTBasePlotter* parent):
|
JKQTPFilledCurveYGraph::JKQTPFilledCurveYGraph(JKQTBasePlotter* parent):
|
||||||
JKQTPFilledCurveGraphBase(parent)
|
JKQTPFilledCurveGraphBase(parent)
|
||||||
{
|
{
|
||||||
@ -233,6 +245,17 @@ JKQTPFilledCurveYGraph::JKQTPFilledCurveYGraph(JKQTPlotter *parent):
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JKQTPFilledCurveYGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
|
||||||
|
{
|
||||||
|
bool res=JKQTPXYGraph::getXMinMax(minx, maxx, smallestGreaterZero);
|
||||||
|
if (getBaseline()>0 && getBaseline()<smallestGreaterZero) {
|
||||||
|
smallestGreaterZero=getBaseline();
|
||||||
|
}
|
||||||
|
minx=qMin(minx,getBaseline());
|
||||||
|
maxx=qMax(maxx,getBaseline());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void JKQTPFilledCurveYGraph::draw(JKQTPEnhancedPainter &painter)
|
void JKQTPFilledCurveYGraph::draw(JKQTPEnhancedPainter &painter)
|
||||||
{
|
{
|
||||||
#ifdef JKQTBP_AUTOTIMER
|
#ifdef JKQTBP_AUTOTIMER
|
||||||
@ -380,6 +403,83 @@ void JKQTPFilledCurveXErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JKQTPFilledCurveXErrorGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
|
||||||
|
{
|
||||||
|
if (yErrorColumn<0 || yErrorStyle==JKQTPNoError) {
|
||||||
|
miny=0;
|
||||||
|
maxy=0;
|
||||||
|
smallestGreaterZero=0;
|
||||||
|
if (getBaseline()>0) {
|
||||||
|
smallestGreaterZero=getBaseline();
|
||||||
|
miny=getBaseline();
|
||||||
|
maxy=getBaseline();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent==nullptr) return false;
|
||||||
|
|
||||||
|
JKQTPDatastore* datastore=parent->getDatastore();
|
||||||
|
int imax=0;
|
||||||
|
int imin=0;
|
||||||
|
if (getIndexRange(imin, imax)) {
|
||||||
|
|
||||||
|
|
||||||
|
for (int i=imin; i<imax; i++) {
|
||||||
|
double yv=getBaseline();
|
||||||
|
if (JKQTPIsOKFloat(yv)) {
|
||||||
|
if (yv>maxy) maxy=yv;
|
||||||
|
if (yv<miny) miny=yv;
|
||||||
|
double xvsgz;
|
||||||
|
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||||
|
}
|
||||||
|
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
|
||||||
|
if (JKQTPIsOKFloat(yv)) {
|
||||||
|
if (yv>maxy) maxy=yv;
|
||||||
|
if (yv<miny) miny=yv;
|
||||||
|
double xvsgz;
|
||||||
|
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bool start=false;
|
||||||
|
miny=getBaseline();
|
||||||
|
maxy=getBaseline();
|
||||||
|
smallestGreaterZero=0;
|
||||||
|
if (getBaseline()>0) {
|
||||||
|
smallestGreaterZero=getBaseline();
|
||||||
|
miny=getBaseline();
|
||||||
|
maxy=getBaseline();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent==nullptr) return false;
|
||||||
|
|
||||||
|
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||||
|
int imax=0;
|
||||||
|
int imin=0;
|
||||||
|
if (getIndexRange(imin, imax)) {
|
||||||
|
|
||||||
|
|
||||||
|
for (int i=imin; i<imax; i++) {
|
||||||
|
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
|
||||||
|
const double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
|
||||||
|
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
|
||||||
|
if (start || yv>maxy) maxy=yv;
|
||||||
|
if (start || yv<miny) miny=yv;
|
||||||
|
double xvsgz;
|
||||||
|
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||||
|
if (start || yvv>maxy) maxy=yvv;
|
||||||
|
if (start || yvv<miny) miny=yvv;
|
||||||
|
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
|
||||||
|
start=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
JKQTPFilledCurveYErrorGraph::JKQTPFilledCurveYErrorGraph(JKQTBasePlotter *parent):
|
JKQTPFilledCurveYErrorGraph::JKQTPFilledCurveYErrorGraph(JKQTBasePlotter *parent):
|
||||||
JKQTPFilledCurveYGraph(parent)
|
JKQTPFilledCurveYGraph(parent)
|
||||||
{
|
{
|
||||||
@ -399,6 +499,83 @@ bool JKQTPFilledCurveYErrorGraph::usesColumn(int c) const
|
|||||||
return JKQTPFilledCurveYGraph::usesColumn(c)|| JKQTPXGraphErrors::errorUsesColumn(c);
|
return JKQTPFilledCurveYGraph::usesColumn(c)|| JKQTPXGraphErrors::errorUsesColumn(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JKQTPFilledCurveYErrorGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
|
||||||
|
{
|
||||||
|
if (xErrorColumn<0 || xErrorStyle==JKQTPNoError) {
|
||||||
|
minx=0;
|
||||||
|
maxx=0;
|
||||||
|
smallestGreaterZero=0;
|
||||||
|
if (getBaseline()>0) {
|
||||||
|
smallestGreaterZero=getBaseline();
|
||||||
|
minx=getBaseline();
|
||||||
|
maxx=getBaseline();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent==nullptr) return false;
|
||||||
|
|
||||||
|
JKQTPDatastore* datastore=parent->getDatastore();
|
||||||
|
int imax=0;
|
||||||
|
int imin=0;
|
||||||
|
if (getIndexRange(imin, imax)) {
|
||||||
|
|
||||||
|
|
||||||
|
for (int i=imin; i<imax; i++) {
|
||||||
|
double yv=getBaseline();
|
||||||
|
if (JKQTPIsOKFloat(yv)) {
|
||||||
|
if (yv>maxx) maxx=yv;
|
||||||
|
if (yv<minx) minx=yv;
|
||||||
|
double xvsgz;
|
||||||
|
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||||
|
}
|
||||||
|
yv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
|
||||||
|
if (JKQTPIsOKFloat(yv)) {
|
||||||
|
if (yv>maxx) maxx=yv;
|
||||||
|
if (yv<minx) minx=yv;
|
||||||
|
double xvsgz;
|
||||||
|
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bool start=false;
|
||||||
|
minx=getBaseline();
|
||||||
|
maxx=getBaseline();
|
||||||
|
smallestGreaterZero=0;
|
||||||
|
if (getBaseline()>0) {
|
||||||
|
smallestGreaterZero=getBaseline();
|
||||||
|
minx=getBaseline();
|
||||||
|
maxx=getBaseline();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent==nullptr) return false;
|
||||||
|
|
||||||
|
const JKQTPDatastore* datastore=parent->getDatastore();
|
||||||
|
int imax=0;
|
||||||
|
int imin=0;
|
||||||
|
if (getIndexRange(imin, imax)) {
|
||||||
|
|
||||||
|
|
||||||
|
for (int i=imin; i<imax; i++) {
|
||||||
|
const double yv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
|
||||||
|
const double yvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
|
||||||
|
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
|
||||||
|
if (start || yv>maxx) maxx=yv;
|
||||||
|
if (start || yv<minx) minx=yv;
|
||||||
|
double xvsgz;
|
||||||
|
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||||
|
if (start || yvv>maxx) maxx=yvv;
|
||||||
|
if (start || yvv<minx) minx=yvv;
|
||||||
|
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
|
||||||
|
start=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void JKQTPFilledCurveYErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)
|
void JKQTPFilledCurveYErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)
|
||||||
{
|
{
|
||||||
if (sortData==JKQTPXYGraph::Unsorted) plotErrorIndicators(painter, parent, this, xColumn, yColumn);
|
if (sortData==JKQTPXYGraph::Unsorted) plotErrorIndicators(painter, parent, this, xColumn, yColumn);
|
||||||
|
@ -64,6 +64,7 @@ public:
|
|||||||
const JKQTPGraphFillStyleMixin& fillStyleBelow() const;
|
const JKQTPGraphFillStyleMixin& fillStyleBelow() const;
|
||||||
/** \copydoc m_fillMode */
|
/** \copydoc m_fillMode */
|
||||||
FillMode getFillMode() const;
|
FillMode getFillMode() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/** \brief set line-color, fill color and symbol color */
|
/** \brief set line-color, fill color and symbol color */
|
||||||
void setColor(QColor c);
|
void setColor(QColor c);
|
||||||
@ -108,6 +109,13 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPFilledCurveXGraph: public JKQTPFilledCurveGrap
|
|||||||
JKQTPFilledCurveXGraph(JKQTPlotter* parent);
|
JKQTPFilledCurveXGraph(JKQTPlotter* parent);
|
||||||
/** \brief plots the graph to the plotter object specified as parent */
|
/** \brief plots the graph to the plotter object specified as parent */
|
||||||
void draw(JKQTPEnhancedPainter &painter) override;
|
void draw(JKQTPEnhancedPainter &painter) override;
|
||||||
|
|
||||||
|
/** \brief get the maximum and minimum y-value of the graph
|
||||||
|
*
|
||||||
|
* The result is given in the two parameters which are call-by-reference parameters!
|
||||||
|
*/
|
||||||
|
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +123,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPFilledCurveXGraph: public JKQTPFilledCurveGrap
|
|||||||
/*! \brief This implements filled curve plots with y errors where the area is filled between the plot line and the x-Axis.
|
/*! \brief This implements filled curve plots with y errors where the area is filled between the plot line and the x-Axis.
|
||||||
\ingroup jkqtplotter_filledgraphs
|
\ingroup jkqtplotter_filledgraphs
|
||||||
|
|
||||||
\image html plot_filledcurvexerrorplots.png
|
\image html JKQTPFilledCurveXErrorGraph.png
|
||||||
|
|
||||||
|
|
||||||
\see \ref JKQTPlotterFilledGraphs, jkqtpstatAddXErrorFilledCurveGraph()
|
\see \ref JKQTPlotterFilledGraphs, jkqtpstatAddXErrorFilledCurveGraph()
|
||||||
@ -129,7 +137,45 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPFilledCurveXErrorGraph: public JKQTPFilledCurv
|
|||||||
JKQTPFilledCurveXErrorGraph(JKQTPlotter* parent);
|
JKQTPFilledCurveXErrorGraph(JKQTPlotter* parent);
|
||||||
/** \copydoc JKQTPGraph::usesColumn() */
|
/** \copydoc JKQTPGraph::usesColumn() */
|
||||||
virtual bool usesColumn(int c) const override;
|
virtual bool usesColumn(int c) const override;
|
||||||
|
/** \brief get the maximum and minimum y-value of the graph
|
||||||
|
*
|
||||||
|
* The result is given in the two parameters which are call-by-reference parameters!
|
||||||
|
*/
|
||||||
|
virtual bool getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) override;
|
||||||
|
|
||||||
|
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::yErrorSymmetric */
|
||||||
|
inline void setValueErrorSymmetric(bool __value) {
|
||||||
|
setYErrorSymmetric(__value);
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::yErrorSymmetric */
|
||||||
|
inline bool getValueErrorSymmetric() const {
|
||||||
|
return getYErrorSymmetric();
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::yErrorColumnLower */
|
||||||
|
inline int getValueErrorColumnLower() const {
|
||||||
|
return getYErrorColumnLower();
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::yErrorColumn */
|
||||||
|
inline int getValueErrorColumn() const {
|
||||||
|
return getYErrorColumn();
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::yErrorStyle */
|
||||||
|
inline void setValueErrorStyle(JKQTPErrorPlotstyle __value) {
|
||||||
|
setYErrorStyle(__value);
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::yErrorStyle */
|
||||||
|
inline JKQTPErrorPlotstyle getValueErrorStyle() const {
|
||||||
|
return getYErrorStyle();
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::yErrorColumn */
|
||||||
|
inline void setValueErrorColumn(int __value) {
|
||||||
|
setYErrorColumn(__value);
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::yErrorColumnLower */
|
||||||
|
inline void setValueErrorColumnLower(int __value) {
|
||||||
|
setYErrorColumnLower(__value);
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
/** \brief this function is used to plot error inidcators before plotting the graphs. */
|
/** \brief this function is used to plot error inidcators before plotting the graphs. */
|
||||||
virtual void drawErrorsAfter(JKQTPEnhancedPainter& painter) override;
|
virtual void drawErrorsAfter(JKQTPEnhancedPainter& painter) override;
|
||||||
@ -169,6 +215,12 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPFilledCurveYGraph: public JKQTPFilledCurveGrap
|
|||||||
/** \brief class constructor */
|
/** \brief class constructor */
|
||||||
JKQTPFilledCurveYGraph(JKQTPlotter* parent);
|
JKQTPFilledCurveYGraph(JKQTPlotter* parent);
|
||||||
|
|
||||||
|
/** \brief get the maximum and minimum x-value of the graph
|
||||||
|
*
|
||||||
|
* The result is given in the two parameters which are call-by-reference parameters!
|
||||||
|
*/
|
||||||
|
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
|
||||||
|
|
||||||
/** \brief plots the graph to the plotter object specified as parent */
|
/** \brief plots the graph to the plotter object specified as parent */
|
||||||
void draw(JKQTPEnhancedPainter &painter) override;
|
void draw(JKQTPEnhancedPainter &painter) override;
|
||||||
/** \brief returns the column used as "key" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
|
/** \brief returns the column used as "key" for the current graph (typically this call getXColumn(), but for horizontal graphs like filled curves or barcharts it may call getYColumn() ) */
|
||||||
@ -188,7 +240,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPFilledCurveYGraph: public JKQTPFilledCurveGrap
|
|||||||
/*! \brief This implements filled curve plots with y errors where the area is filled between the plot line and the x-Axis.
|
/*! \brief This implements filled curve plots with y errors where the area is filled between the plot line and the x-Axis.
|
||||||
\ingroup jkqtplotter_filledgraphs
|
\ingroup jkqtplotter_filledgraphs
|
||||||
|
|
||||||
\image html plot_filledcurveyerrorplots.png
|
\image html JKQTPFilledCurveYErrorGraph.png
|
||||||
|
|
||||||
\see \ref JKQTPlotterFilledGraphs, jkqtpstatAddYErrorFilledCurveGraph()
|
\see \ref JKQTPlotterFilledGraphs, jkqtpstatAddYErrorFilledCurveGraph()
|
||||||
*/
|
*/
|
||||||
@ -201,6 +253,45 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPFilledCurveYErrorGraph: public JKQTPFilledCurv
|
|||||||
/** \copydoc JKQTPGraph::usesColumn() */
|
/** \copydoc JKQTPGraph::usesColumn() */
|
||||||
virtual bool usesColumn(int c) const override;
|
virtual bool usesColumn(int c) const override;
|
||||||
|
|
||||||
|
/** \brief get the maximum and minimum x-value of the graph
|
||||||
|
*
|
||||||
|
* The result is given in the two parameters which are call-by-reference parameters!
|
||||||
|
*/
|
||||||
|
virtual bool getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) override;
|
||||||
|
|
||||||
|
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::xErrorSymmetric */
|
||||||
|
inline void setValueErrorSymmetric(bool __value) {
|
||||||
|
setXErrorSymmetric(__value);
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::xErrorSymmetric */
|
||||||
|
inline bool getValueErrorSymmetric() const {
|
||||||
|
return getXErrorSymmetric();
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::xErrorColumnLower */
|
||||||
|
inline int getValueErrorColumnLower() const {
|
||||||
|
return getXErrorColumnLower();
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::xErrorColumn */
|
||||||
|
inline int getValueErrorColumn() const {
|
||||||
|
return getXErrorColumn();
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::xErrorStyle */
|
||||||
|
inline void setValueErrorStyle(JKQTPErrorPlotstyle __value) {
|
||||||
|
setXErrorStyle(__value);
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::xErrorStyle */
|
||||||
|
inline JKQTPErrorPlotstyle getValueErrorStyle() const {
|
||||||
|
return getXErrorStyle();
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::xErrorColumn */
|
||||||
|
inline void setValueErrorColumn(int __value) {
|
||||||
|
setXErrorColumn(__value);
|
||||||
|
}
|
||||||
|
/** \copydoc JKQTPFilledCurveXGraph::xErrorColumnLower */
|
||||||
|
inline void setValueErrorColumnLower(int __value) {
|
||||||
|
setXErrorColumnLower(__value);
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
/** \brief this function is used to plot error inidcators before plotting the graphs. */
|
/** \brief this function is used to plot error inidcators before plotting the graphs. */
|
||||||
virtual void drawErrorsAfter(JKQTPEnhancedPainter& painter) override;
|
virtual void drawErrorsAfter(JKQTPEnhancedPainter& painter) override;
|
||||||
|
BIN
screenshots/filledgraphs_errors.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
screenshots/filledgraphs_errors_small.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
screenshots/filledgraphs_errors_y.png
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
screenshots/filledgraphs_errors_y_small.png
Normal file
After Width: | Height: | Size: 15 KiB |