diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index f3704ca519..644e8f7d83 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -54,10 +54,11 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
autoAxisSpacing=true
.
+
+ \section jkqtplotter_coordinateaxes_tickscaling Axis Tick Units/Scaling
+ In some cases it is desired to put the axis ticks not at 1,2,3,... but rather at \f$ 1\pi \f$ , \f$ 2\pi \f$ , \f$ 3\pi \f$ or any other
+ unit than \f$ pi \f$ ,i.e.:
+
+ \image html axisstyle/axis_unit_scaling_none.png "no axis scaling (default case)"
+ \image html axisstyle/axis_unit_scaling_pi.png "pi-axis scaling (default case)"
+
+ You can use these methods to set such a factor:
+ - setTickUnitFactor() for the actual factor and setTickUnitName() for a name, added to the tick label
+ - setTickUnit() sets factor and name in one call
+ - setTickUnitPi() shortcut to set pi-scaling
+ - resetTickUnit() resets to no-scaling (default case)
+ .
+
*/
class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
Q_OBJECT
@@ -171,7 +185,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
virtual void saveSettings(QSettings& settings, const QString& group=QString("plots/axes/")) const;
- /** \brief return x-pixel coordinate from time coordinate */
+ /** \brief return x-pixel coordinate from x coordinate */
inline double x2p(double x) const {
double r=0;
if (logAxis) {
@@ -187,7 +201,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
}
}
- /** \brief return time coordinate coordinate from x-pixel */
+ /** \brief return x coordinate from x-pixel */
inline double p2x(double x) const {
double xx=x;
if (inverted) {
@@ -253,6 +267,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
inline JKQTPCALabelType getTickLabelType() const { return this->axisStyle.tickLabelType; }
/** \copydoc axisLabel */
inline QString getAxisLabel() const { return this->axisLabel; }
+ /** \copydoc tickUnitFactor */
+ inline double getTickUnitFactor() const { return this->tickUnitFactor; }
+ /** \copydoc tickUnitName */
+ inline QString getTickUnitName() const { return this->tickUnitName; }
/** \copydoc JKQTPCoordinateAxisStyle::labelPosition */
inline JKQTPLabelPosition getLabelPosition() const { return this->axisStyle.labelPosition; }
/** \copydoc JKQTPCoordinateAxisStyle::labelFontSize */
@@ -465,6 +483,28 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
/** \copydoc axisLabel */
void setAxisLabel (const QString& __value);
+ /** \copydoc tickUnitName */
+ void setTickUnitName(const QString& __value);
+
+ /** \copydoc tickUnitFactor */
+ void setTickUnitFactor(double __value);
+ /** \brief sets tickUnitFactor and tickUnitName in one call
+ *
+ * \see calls setTickUnitName() and setTickUnitFactor()
+ */
+ void setTickUnit(double factor, const QString& name);
+ /** \brief sets pi-scaling for tickUnitFactor and tickUnitName in one call
+ *
+ * \image html axisstyle/axis_unit_scaling_pi.png
+ * \see calls setTickUnitName() and setTickUnitFactor()
+ */
+ void setTickUnitPi();
+ /** \brief resets tickUnitFactor and tickUnitName in one call
+ *
+ * \see calls setTickUnit(), setTickUnitName() and setTickUnitFactor()
+ */
+ void resetTickUnit();
+
/** \copydoc JKQTPCoordinateAxisStyle::labelPosition */
void setLabelPosition (JKQTPLabelPosition __value);
@@ -627,9 +667,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
QString floattolabel(double data, int past_comma) const;
/** \brief parent plotter class */
JKQTBasePlotter* parent;
- /** \brief current view: minimum of time axis */
+ /** \brief current view: minimum of axis */
double axismin;
- /** \brief current view: maximum of time axis */
+ /** \brief current view: maximum of axis */
double axismax;
/** \brief absoulte minimum of axis (axismin/axismax xan not be set below this) */
@@ -647,18 +687,18 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
/** \brief absolute minimum range width, feature switched off when <0 */
double axisMinWidth;
- /** \brief calculated property: width of plot on time axis (calculated by calcPlotScaling() )
+ /** \brief calculated property: width of plot on axis (calculated by calcPlotScaling() )
*
* \see calcPlotScaling(), calcTickSpacing()
*/
double width;
- /** \brief calculated property: time axis scaling factor (calculated by calcPlotScaling() )
+ /** \brief calculated property: axis scaling factor (calculated by calcPlotScaling() )
*
* \see calcPlotScaling(), calcTickSpacing()
*/
double scale;
- /** \brief calculated property: time axis offset (calculated by calcPlotScaling() )
+ /** \brief calculated property: axis offset (calculated by calcPlotScaling() )
*
* \see calcPlotScaling(), calcTickSpacing()
*/
@@ -709,6 +749,12 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
/** \brief axis label of the axis */
QString axisLabel;
+ /** \brief tick values are the actual x/y-coordiniate, divided by this value (e.g. pu \f$ \pi \f$ to have an axis with values 0, pi, 2pi, 3pi ...) */
+ double tickUnitFactor;
+
+ /** \brief name of the factor tickUnitFactor. This string is used in tick-labels to write e.g. \c "2pi" instead of 6.28... */
+ QString tickUnitName;
+
/** \brief calculates the tick spacing for a linear axis that spans \a awidth and that should
* show at least \a JKQTPCoordinateAxisStyle::minTicks JKQTPCoordinateAxisStyle::ticks.
diff --git a/lib/jkqtplotter/jkqtptools.h b/lib/jkqtplotter/jkqtptools.h
index 066fa70334..8ae288abb3 100644
--- a/lib/jkqtplotter/jkqtptools.h
+++ b/lib/jkqtplotter/jkqtptools.h
@@ -445,7 +445,7 @@ enum JKQTPCALabelType {
JKQTPCALTscientific, /*!< \brief print the numbers in scientific notation, e.g. \c "1.23e-4" \image html axisstyle/JKQTPCALTscientific.png */
JKQTPCALTexponentCharacter, /*!< \brief print the numbers and show a unit character, i.e. 5μ for \f$ 5\cdot 10^{-6} \f$ , \c 3k for \f$ 3\cdot 10^3 \f$ ... \image html axisstyle/JKQTPCALTexponentCharacter.png */
JKQTPCALTexponent, /*!< \brief show numbers in exponential for, e.g. \f$ 3\cdot 10^5 \f$ ... \image html axisstyle/JKQTPCALTexponent.png */
- JKQTPCALTprintf, /*!< \brief generate axis label from an arbitrary "printf" formatting string (see e.g. https://en.wikipedia.org/wiki/Printf_format_string ). The only data parameter is the tick value as \c double The following image shows an example for \c "y=%+.2f": \image html axisstyle/JKQTPCALTprintf.png */
+ JKQTPCALTprintf, /*!< \brief generate axis label from an arbitrary "printf" formatting string (see e.g. https://en.wikipedia.org/wiki/Printf_format_string ). The first data parameter is the tick value as \c double an the second is tickUnitName as string. The following image shows an example for \c "y=%+.2f": \image html axisstyle/JKQTPCALTprintf.png */
JKQTPCALTdate, /*!< \brief show numbers as dates \image html axisstyle/JKQTPCALTdate.png */
JKQTPCALTtime, /*!< \brief show numbers as times \image html axisstyle/JKQTPCALTtime.png*/
JKQTPCALTdatetime, /*!< \brief show numbers as times \image html axisstyle/JKQTPCALTdatetime.png */
@@ -465,9 +465,9 @@ enum JKQTPCALabelType {
/** \brief mode of the axis ticks
* \ingroup jkqtpplottersupprt */
enum JKQTPLabelTickMode {
- JKQTPLTMLinOrPower=0, /*!< \brief linear, or log, depending on whether the axis is log */
- JKQTPLTMLin, /*!< \brief always linear (even for log-axes) */
- JKQTPLTMPower, /*!< \brief powers (of the log-base) */
+ JKQTPLTMLinOrPower=0, /*!< \brief linear, or log, depending on whether the axis is log \image html axisstyle/JKQTPLTMLinOrPower.png */
+ JKQTPLTMLin, /*!< \brief always linear (even for log-axes) \image html axisstyle/JKQTPLTMLin.png */
+ JKQTPLTMPower, /*!< \brief powers (of the log-base) \image html axisstyle/JKQTPLTMPower.png */
JKQTPLTMmax=JKQTPLTMPower
};
diff --git a/screenshots/imageplot_userpal_program.png b/screenshots/imageplot_userpal_program.png
index ac5ca34050..4977c1984f 100644
Binary files a/screenshots/imageplot_userpal_program.png and b/screenshots/imageplot_userpal_program.png differ
diff --git a/screenshots/imageplot_userpal_program_small.png b/screenshots/imageplot_userpal_program_small.png
index 6d61f7f685..b96d8f4804 100644
Binary files a/screenshots/imageplot_userpal_program_small.png and b/screenshots/imageplot_userpal_program_small.png differ
diff --git a/screenshots/multiplot_controlwindow.png b/screenshots/multiplot_controlwindow.png
index 5fe791c503..bf548904a3 100644
Binary files a/screenshots/multiplot_controlwindow.png and b/screenshots/multiplot_controlwindow.png differ
diff --git a/screenshots/multiplot_controlwindow_small.png b/screenshots/multiplot_controlwindow_small.png
index 8e87106b18..b755e78628 100644
Binary files a/screenshots/multiplot_controlwindow_small.png and b/screenshots/multiplot_controlwindow_small.png differ
diff --git a/screenshots/parsedfunctionplot.png b/screenshots/parsedfunctionplot.png
index acf6e9ed10..95b809f321 100644
Binary files a/screenshots/parsedfunctionplot.png and b/screenshots/parsedfunctionplot.png differ
diff --git a/screenshots/parsedfunctionplot_small.png b/screenshots/parsedfunctionplot_small.png
index 6d282f9ad1..54e5e34dfa 100644
Binary files a/screenshots/parsedfunctionplot_small.png and b/screenshots/parsedfunctionplot_small.png differ
diff --git a/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp b/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp
index 19d4bebf39..442b82ad6f 100644
--- a/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp
+++ b/tools/jkqtplotter_doc_imagegenerator/jkqtplotter_doc_imagegenerator.cpp
@@ -312,6 +312,62 @@ void doListAxisStyling(const QDir& outputDir, int iconsize, QColor backgroundCol
plot.getXAxis()->setDrawMode1(JKQTPCADMLine|JKQTPCADMcompleteMinMaxArrow);
imgheight=iconsize; plot.grabPixelImage(QSize(plot.getWidth(),plot.getHeight()), false).copy(0,plot.getHeight()-imgheight,plot.getWidth(),imgheight).save(outputDir.absoluteFilePath("JKQTPCADMcompleteMinMaxArrow.png"), "png");
+
+ plot.setXY(0.1,100,0.1,10);
+ plot.setWidgetSize(iconsize*4,4*iconsize);
+ plot.setShowKey(false);
+ plot.setGrid(true);
+ plot.getXAxis()->setLogAxis(true);
+ plot.getYAxis()->setLogAxis(false);
+ plot.getXAxis()->setShowZeroAxis(false);
+ plot.getYAxis()->setShowZeroAxis(false);
+ plot.getXAxis()->setDrawMode1(JKQTPCADMcomplete);
+ plot.getXAxis()->setDrawMode2(JKQTPCADMLine);
+ plot.getYAxis()->setDrawMode1(JKQTPCADMcomplete);
+ plot.getYAxis()->setDrawMode2(JKQTPCADMLine);
+ plot.getXAxis()->setAxisLabel("log. axis");
+ plot.getYAxis()->setAxisLabel("lin. axis");
+
+ plot.getXAxis()->setTickMode(JKQTPLTMLinOrPower);
+ plot.getYAxis()->setTickMode(JKQTPLTMLinOrPower);
+ plot.grabPixelImage(QSize(plot.getWidth(),plot.getHeight()), false).copy(0,0,plot.getWidth(),plot.getHeight()).save(outputDir.absoluteFilePath("JKQTPLTMLinOrPower.png"), "png");
+
+ plot.getXAxis()->setTickMode(JKQTPLTMLin);
+ plot.getYAxis()->setTickMode(JKQTPLTMLin);
+ plot.grabPixelImage(QSize(plot.getWidth(),plot.getHeight()), false).copy(0,0,plot.getWidth(),plot.getHeight()).save(outputDir.absoluteFilePath("JKQTPLTMLin.png"), "png");
+
+ plot.getXAxis()->setTickMode(JKQTPLTMPower);
+ plot.getYAxis()->setTickMode(JKQTPLTMPower);
+ plot.grabPixelImage(QSize(plot.getWidth(),plot.getHeight()), false).copy(0,0,plot.getWidth(),plot.getHeight()).save(outputDir.absoluteFilePath("JKQTPLTMPower.png"), "png");
+
+
+
+ plot.setXY(0.1,10.0*JKQTPSTATISTICS_PI,0,2.1*JKQTPSTATISTICS_PI);
+ plot.setWidgetSize(iconsize*4,4*iconsize);
+ plot.setShowKey(false);
+ plot.setGrid(true);
+ plot.getXAxis()->setLogAxis(true);
+ plot.getYAxis()->setLogAxis(false);
+ plot.getXAxis()->setShowZeroAxis(false);
+ plot.getYAxis()->setShowZeroAxis(false);
+ plot.getXAxis()->setDrawMode1(JKQTPCADMcomplete);
+ plot.getXAxis()->setDrawMode2(JKQTPCADMLine);
+ plot.getYAxis()->setDrawMode1(JKQTPCADMcomplete);
+ plot.getYAxis()->setDrawMode2(JKQTPCADMLine);
+ plot.getXAxis()->setAxisLabel("log. axis");
+ plot.getYAxis()->setAxisLabel("lin. axis");
+ plot.getXAxis()->setMinTicks(5);
+ plot.getYAxis()->setMinTicks(3);
+ plot.getYAxis()->setTickLabelType(JKQTPCALTfrac);
+
+ plot.getXAxis()->setTickMode(JKQTPLTMLinOrPower);
+ plot.getYAxis()->setTickMode(JKQTPLTMLinOrPower);
+ plot.grabPixelImage(QSize(plot.getWidth(),plot.getHeight()), false).copy(0,0,plot.getWidth(),plot.getHeight()).save(outputDir.absoluteFilePath("axis_unit_scaling_none.png"), "png");
+ plot.getXAxis()->setTickUnitFactor(JKQTPSTATISTICS_PI);
+ plot.getXAxis()->setTickUnitName("\\;\\pi");
+ plot.getYAxis()->setTickUnitFactor(JKQTPSTATISTICS_PI);
+ plot.getYAxis()->setTickUnitName("\\;\\pi");
+ plot.grabPixelImage(QSize(plot.getWidth(),plot.getHeight()), false).copy(0,0,plot.getWidth(),plot.getHeight()).save(outputDir.absoluteFilePath("axis_unit_scaling_pi.png"), "png");
}
int main(int argc, char* argv[])