mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 01:51:49 +08:00
RENAMED JKQTPDatastore::addColumnCalculatedFromColumn() to JKQTPDatastore::addCalculatedColumnFromColumn(), which is more in line with the other add...()-function names. Aliases with the old function names remain for compatibility
This commit is contained in:
parent
b338606bc1
commit
f606327469
@ -78,6 +78,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
||||
<li>IMPROVED: documentation of styles: automatized doc image generation.</li>
|
||||
<li>IMPROVED: axis labeling: there were some minor differences between compilers</li>
|
||||
<li>IMPROVED: jkqtp_floattounitstr()/jkqtp_floattolatexunitstr(): add all SI-Prefixes from 10^-30...10^30</li>
|
||||
<li>RENAMED JKQTPDatastore::addColumnCalculatedFromColumn() to JKQTPDatastore::addCalculatedColumnFromColumn(), which is more in line with the other add...()-function names. Aliases with the old function names remain for compatibility</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/BREAKING CHANGE: data tooltip can now also be shown when "just" moving the mouse (so far this was only possible when dragging the mouse with a button pressed). This also removes JKQtPlotter::getActMouseLeftAsToolTip() and adds JKQtPlotter::getActMouseMoveToolTip() instead! Also the default toolbars and context menus changed!</li>
|
||||
<li>NEW: new "seaborn" style for plots, see \ref jkqtpplotter_styling </li>
|
||||
|
@ -21,7 +21,7 @@ void doExample(JKQTPlotter& plot, const QString& title)
|
||||
|
||||
// 2. now we create two columns for key and value
|
||||
size_t columnK=ds->addLinearColumn(7, 0, 6, "k");
|
||||
size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return jkqtp_sign(2.0*x-2.5)*qMax(2.0,fabs(2.0*x-2.5)); }, "v");
|
||||
size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return jkqtp_sign(2.0*x-2.5)*qMax(2.0,fabs(2.0*x-2.5)); }, "v");
|
||||
|
||||
// 3. load a stylesheet
|
||||
plot.loadCurrentPlotterStyle(QSettings(":/JKQTPlotter/styles/seaborn.ini", QSettings::IniFormat));
|
||||
|
@ -22,8 +22,8 @@ void doExample(JKQTPlotter& plot, const QString& title)
|
||||
|
||||
// 2. now we create three columns for key and value
|
||||
size_t columnK=ds->addLinearColumn(6, 0.4*JKQTPSTATISTICS_PI, 2.2*JKQTPSTATISTICS_PI,"k");
|
||||
size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return cos(x); }, "v");
|
||||
size_t columnE=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return 0.05+0.06*(1.0+sin(x)); }, "error");
|
||||
size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return cos(x); }, "v");
|
||||
size_t columnE=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return 0.05+0.06*(1.0+sin(x)); }, "error");
|
||||
|
||||
// 3. create a graph in the plot, which plots the dataset with symmetric:
|
||||
TCHART* graph1=new TCHART(&plot);
|
||||
|
@ -21,7 +21,7 @@ void doExample(JKQTPlotter& plot, const QString& title)
|
||||
|
||||
// 2. now we create two columns for key and value
|
||||
size_t columnK=ds->addLinearColumn(11, 0, 10, "k");
|
||||
size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return 5.0+x; }, "v");
|
||||
size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return 5.0+x; }, "v");
|
||||
|
||||
// 3. create graph in the plot, which plots the dataset:
|
||||
JKQTPBarGraphBase* graph=new TCHART(&plot);
|
||||
|
@ -22,7 +22,7 @@ void doExample(JKQTPlotter& plot, const QString& title)
|
||||
|
||||
// 2. now we create two columns for key and value
|
||||
size_t columnK=ds->addLinearColumn(15, 0.5*JKQTPSTATISTICS_PI, 3.0*JKQTPSTATISTICS_PI,"k");
|
||||
size_t columnV=ds->addColumnCalculatedFromColumn(columnK, [](double x) { return cos(x); }, "v");
|
||||
size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return cos(x); }, "v");
|
||||
|
||||
// 3. create graph in the plot, which plots the dataset:
|
||||
JKQTPBarGraphBase* graph=new TCHART(&plot);
|
||||
|
@ -125,8 +125,8 @@ int main(int argc, char* argv[])
|
||||
datastore->setPixel(imgColumn2, ix, iy, sin(ix*iy/30.0));
|
||||
}
|
||||
}
|
||||
// the loop above can be written more compact using addColumnCalculatedFromColumn():
|
||||
//imgColumn=datastore->addColumnCalculatedFromColumn(colLinXY.first, colLinXY.second, [](double x, double y)->double { return cos((x-15.0))/(x-15.0)*cos((y-2.0))/(x-2.0); }, "image value");
|
||||
// the loop above can be written more compact using addCalculatedColumnFromColumn():
|
||||
//imgColumn=datastore->addCalculatedColumnFromColumn(colLinXY.first, colLinXY.second, [](double x, double y)->double { return cos((x-15.0))/(x-15.0)*cos((y-2.0))/(x-2.0); }, "image value");
|
||||
// finally we can use a JKQTPXYParametrizedScatterGraph to display the data from our three columns
|
||||
// by using colLinXY->first and colLinXY->second as positions for symbols that are colored, based
|
||||
// on the respective value in imgColumn:
|
||||
|
@ -24,12 +24,12 @@ void doExample(JKQTPlotter& plot, const QString& title)
|
||||
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, [](double x) { return sin(x); }, "v");
|
||||
size_t columnV2=ds->addColumnCalculatedFromColumn(columnK2, [](double x) { return -sin(x); }, "v2");
|
||||
size_t columnV3=ds->addColumnCalculatedFromColumn(columnK3, [](double x) { return sin(x); }, "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");
|
||||
size_t columnV=ds->addCalculatedColumnFromColumn(columnK, [](double x) { return sin(x); }, "v");
|
||||
size_t columnV2=ds->addCalculatedColumnFromColumn(columnK2, [](double x) { return -sin(x); }, "v2");
|
||||
size_t columnV3=ds->addCalculatedColumnFromColumn(columnK3, [](double x) { return sin(x); }, "v3");
|
||||
size_t columnE=ds->addCalculatedColumnFromColumn(columnV, [](double x) { return 0.2*x; }, "error");
|
||||
size_t columnE2=ds->addCalculatedColumnFromColumn(columnV2, [](double x) { return 0.2*x; }, "error");
|
||||
size_t columnE3=ds->addCalculatedColumnFromColumn(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);
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
JKQTPXYLineGraph* g;
|
||||
plot.addGraph(g=new JKQTPXYLineGraph(&plot));
|
||||
g->setXColumn(colX);
|
||||
g->setYColumn(plot.getDatastore()->addColumnCalculatedFromColumn(colX, [&](double x) { return cos(x+double(i+plotIndex)/8.0*JKQTPSTATISTICS_PI)+rng.generateDouble()*0.2-0.1;}));
|
||||
g->setYColumn(plot.getDatastore()->addCalculatedColumnFromColumn(colX, [&](double x) { return cos(x+double(i+plotIndex)/8.0*JKQTPSTATISTICS_PI)+rng.generateDouble()*0.2-0.1;}));
|
||||
g->setTitle(labeltemplate.arg(i+plotIndex+1));
|
||||
g->setDrawLine(true);
|
||||
g->setSymbolType(JKQTPNoSymbol);
|
||||
|
@ -19,10 +19,10 @@ void exampleSecondYAxis(JKQTPlotter& plot, const QString& title)
|
||||
|
||||
// 2. now we create two columns for key and value
|
||||
size_t columnX=ds->addLinearColumn(40, 0,10,"x");
|
||||
size_t columnY1=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return x; }, "y1");
|
||||
size_t columnY2=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return cos(x); }, "y2");
|
||||
size_t columnY3=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return x*x; }, "y3");
|
||||
size_t columnY4=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return sqrt(x); }, "y3");
|
||||
size_t columnY1=ds->addCalculatedColumnFromColumn(columnX, [](double x) { return x; }, "y1");
|
||||
size_t columnY2=ds->addCalculatedColumnFromColumn(columnX, [](double x) { return cos(x); }, "y2");
|
||||
size_t columnY3=ds->addCalculatedColumnFromColumn(columnX, [](double x) { return x*x; }, "y3");
|
||||
size_t columnY4=ds->addCalculatedColumnFromColumn(columnX, [](double x) { return sqrt(x); }, "y3");
|
||||
|
||||
// 3. create a second y-axis and set its formating options, so it only draws an axis on the right
|
||||
auto yAxisRef2=plot.getPlotter()->addSecondaryYAxis(new JKQTPVerticalAxis(plot.getPlotter(), JKQTPPrimaryAxis));
|
||||
@ -113,10 +113,10 @@ void exampleSecondXAxis(JKQTPlotter& plot, const QString& title)
|
||||
JKQTPDatastore* ds=plot.getDatastore();
|
||||
|
||||
size_t columnY=ds->addLinearColumn(30, 0,12,"y");
|
||||
size_t columnX1=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return x; }, "x1");
|
||||
size_t columnX2=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return cos(x); }, "x2");
|
||||
size_t columnX3=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return x*x; }, "x3");
|
||||
size_t columnX4=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return sqrt(x); }, "x4");
|
||||
size_t columnX1=ds->addCalculatedColumnFromColumn(columnY, [](double x) { return x; }, "x1");
|
||||
size_t columnX2=ds->addCalculatedColumnFromColumn(columnY, [](double x) { return cos(x); }, "x2");
|
||||
size_t columnX3=ds->addCalculatedColumnFromColumn(columnY, [](double x) { return x*x; }, "x3");
|
||||
size_t columnX4=ds->addCalculatedColumnFromColumn(columnY, [](double x) { return sqrt(x); }, "x4");
|
||||
|
||||
JKQTPXYLineGraph* graph1=new JKQTPXYLineGraph(&plot);
|
||||
graph1->setXColumn(columnX1);
|
||||
|
@ -814,7 +814,7 @@ size_t JKQTPDatastore::addCalculatedImageColumn(size_t cols, size_t rows, const
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
size_t JKQTPDatastore::addColumnCalculatedFromColumn(size_t otherColumn, const std::function<double (double)> &f, const QString &name)
|
||||
size_t JKQTPDatastore::addCalculatedColumnFromColumn(size_t otherColumn, const std::function<double (double)> &f, const QString &name)
|
||||
{
|
||||
const JKQTPColumn& oc=columns.value(otherColumn);
|
||||
JKQTPDatastoreItem* it=new JKQTPDatastoreItem(1, oc.getRows());
|
||||
@ -826,7 +826,7 @@ size_t JKQTPDatastore::addColumnCalculatedFromColumn(size_t otherColumn, const s
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
size_t JKQTPDatastore::addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function<double (double, double)> &f, const QString &name)
|
||||
size_t JKQTPDatastore::addCalculatedColumnFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function<double (double, double)> &f, const QString &name)
|
||||
{
|
||||
const JKQTPColumn& ocx=columns.value(otherColumnX);
|
||||
const JKQTPColumn& ocy=columns.value(otherColumnY);
|
||||
|
@ -124,7 +124,7 @@ enum class JKQTPDatastoreItemFormat {
|
||||
* <li> addLinearGridColumns() adds two columns which represent x- and y- coordinates of points
|
||||
* on a rectangular grid (useful for calculating image data)
|
||||
* <li> addCalculatedColumn() calculates a column, based on row numbers and a C++ functor
|
||||
* <li> addColumnCalculatedFromColumn() calculates a column, based on another column data
|
||||
* <li> addCalculatedColumnFromColumn() calculates a column, based on another column data
|
||||
* <li> addCopiedMap() copies data from a std::map/QMap into two columns
|
||||
* <li> ... several more functions for specific cases exist.
|
||||
* <li> Also note that there are even library extensions that allow to import data directly from OpenCV matrices: JKQTPCopyCvMatToColumn()
|
||||
@ -1252,7 +1252,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{
|
||||
* x-coordinates are linearly distributed between \a startX and \a endX and the x-coordinates are linearly
|
||||
* distributed between \a startY and \a endY .
|
||||
*
|
||||
* \see addLogGridColumns(), addDecadeLogGridColumns(), addColumnCalculatedFromColumn(), JKQTPXYParametrizedScatterGraph, \ref JKQTPlotterBasicJKQTPDatastore
|
||||
* \see addLogGridColumns(), addDecadeLogGridColumns(), addCalculatedColumnFromColumn(), JKQTPXYParametrizedScatterGraph, \ref JKQTPlotterBasicJKQTPDatastore
|
||||
*/
|
||||
std::pair<size_t,size_t> addLinearGridColumns(size_t width, double startX, double endX, size_t height, double startY, double endY, const QString& nameX=QString(""), const QString& nameY=QString(""));
|
||||
|
||||
@ -1267,7 +1267,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{
|
||||
* return newColumn;
|
||||
* \endcode
|
||||
*
|
||||
* \see addColumnCalculatedFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore
|
||||
* \see addCalculatedColumnFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore
|
||||
*/
|
||||
size_t addCalculatedColumn(size_t rows, const std::function<double(size_t, JKQTPDatastore*)>& f, const QString& name=QString(""));
|
||||
/** \brief add a column with \a rows entries, that is calculated by calling \a f for each entry
|
||||
@ -1280,7 +1280,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{
|
||||
* return newColumn;
|
||||
* \endcode
|
||||
*
|
||||
* \see addColumnCalculatedFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore
|
||||
* \see addCalculatedColumnFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore
|
||||
*/
|
||||
size_t addCalculatedColumn(size_t rows, const std::function<double(size_t)>& f, const QString& name=QString(""));
|
||||
/** \brief add an image column with width \a cols and height \a rows (i.e. \a rows * \a cols entries), that is calculated by calling \a f for each entry
|
||||
@ -1295,7 +1295,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{
|
||||
* return newColumn;
|
||||
* \endcode
|
||||
*
|
||||
* \see addColumnCalculatedFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore
|
||||
* \see addCalculatedColumnFromColumn(), \ref JKQTPlotterBasicJKQTPDatastore
|
||||
*/
|
||||
size_t addCalculatedImageColumn(size_t cols, size_t rows, const std::function<double(size_t,size_t)>& f, const QString& name=QString(""));
|
||||
/** \brief add a column with the same number of entries, as in the other column \a otherColumn , that are calculated by calling \a f for each entry in \a otherColumn
|
||||
@ -1310,7 +1310,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{
|
||||
*
|
||||
* \see addCalculatedColumn(), \ref JKQTPlotterBasicJKQTPDatastore
|
||||
*/
|
||||
size_t addColumnCalculatedFromColumn(size_t otherColumn, const std::function<double(double)>& f, const QString& name=QString(""));
|
||||
size_t addCalculatedColumnFromColumn(size_t otherColumn, const std::function<double(double)>& f, const QString& name=QString(""));
|
||||
inline size_t addColumnCalculatedFromColumn(size_t otherColumn, const std::function<double(double)>& f, const QString& name=QString("")) {
|
||||
return addCalculatedColumnFromColumn(otherColumn, f, name);
|
||||
}
|
||||
/** \brief add a column with the same number of entries, as in the other column \a otherColumn , that are calculated by calling \a f for each pair of entries in \a otherColumnX and \a otherColumnY
|
||||
*
|
||||
* Pseudocode:
|
||||
@ -1323,7 +1326,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{
|
||||
*
|
||||
* \see addCalculatedColumn(), \ref JKQTPlotterBasicJKQTPDatastore
|
||||
*/
|
||||
size_t addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function<double(double,double)>& f, const QString& name=QString(""));
|
||||
size_t addCalculatedColumnFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function<double(double,double)>& f, const QString& name=QString(""));
|
||||
inline size_t addColumnCalculatedFromColumn(size_t otherColumnX, size_t otherColumnY, const std::function<double(double,double)>& f, const QString& name=QString("")) {
|
||||
return addCalculatedColumnFromColumn(otherColumnX, otherColumnY, f, name);
|
||||
}
|
||||
|
||||
/** \brief returns the number of (logical) columns currently managed by the datastore */
|
||||
inline size_t getColumnCount() const { return static_cast<size_t>(columns.size()); }
|
||||
|
@ -637,9 +637,9 @@ void doListKeyPositions(const QDir& outputDir, int iconsize, QColor /*background
|
||||
|
||||
|
||||
const size_t colX=plot.getDatastore()->addLinearColumn(30,0,1);
|
||||
const size_t colY1=plot.getDatastore()->addColumnCalculatedFromColumn(colX, [](double x) { return x; });
|
||||
const size_t colY2=plot.getDatastore()->addColumnCalculatedFromColumn(colX, [](double x) { return x*x; });
|
||||
const size_t colY3=plot.getDatastore()->addColumnCalculatedFromColumn(colX, [](double x) { return sqrt(x); });
|
||||
const size_t colY1=plot.getDatastore()->addCalculatedColumnFromColumn(colX, [](double x) { return x; });
|
||||
const size_t colY2=plot.getDatastore()->addCalculatedColumnFromColumn(colX, [](double x) { return x*x; });
|
||||
const size_t colY3=plot.getDatastore()->addCalculatedColumnFromColumn(colX, [](double x) { return sqrt(x); });
|
||||
JKQTPXYLineGraph* g;
|
||||
plot.addGraph(g=new JKQTPXYLineGraph(&plot));
|
||||
g->setTitle("linear");
|
||||
@ -688,7 +688,7 @@ void doListKeyLayouts(const QDir& outputDir, int iconsize, QColor /*backgroundCo
|
||||
JKQTPXYLineGraph* g;
|
||||
const size_t colX=plot.getDatastore()->addLinearColumn(70,0,1);
|
||||
for (int i=0; i<8; i++) {
|
||||
const size_t colY1=plot.getDatastore()->addColumnCalculatedFromColumn(colX, [i](double x) { return pow(x, pow(2,(i-4)/4.0)); });
|
||||
const size_t colY1=plot.getDatastore()->addCalculatedColumnFromColumn(colX, [i](double x) { return pow(x, pow(2,(i-4)/4.0)); });
|
||||
plot.addGraph(g=new JKQTPXYLineGraph(&plot));
|
||||
g->setTitle(QString::number(i+1)+": $f(x)=x^{"+QString::number(pow(2,(i-4)/4.0), 'f', 2)+"}$");
|
||||
g->setDrawLine(true);
|
||||
|
Loading…
Reference in New Issue
Block a user