pyqtgraph/examples
Lev Maximov a76d9daec2
Date axis item (#1154)
* Add DateAxisItem

* Change style to camelCase

* Fix missing first tick for negative timestamps

* Add ms precision, auto skipping

Auto skipping allows a zoom level to skip ticks automatically if the
maximum number of ticks/pt is exceeded

* fixes suggested by @goetzc

* workaround for negative argument to utcfromtimestamp on windows

* attachToPlotItem method

* default date axis orientation

* Use new DateAxisItem in Plot Customization example

* attachToPlotItem bugfix

* examples of DateAxisItem

* modified description of customPlot example

* added descriptions to the new examples, reformatted their code, included the first one into utils.py

* typo

* Refactored code for setting axis items into new function

Replaces "DateAxisItem.attachToPlotItem"

* Fix string comparison with ==

* Doc: Slightly more text for DateAxisItem, small improvement for PlotItem

* Make PlotWidget.setAxisItems official

* Fix typo in docstring

* renamed an example

* merge bug fix

* Revert "merge bug fix"

This reverts commit 876b5a7cdb.

* Real bug fix

* support for dates upto -1e13..1e13

* Automatically limit DateAxisItem to a range from -1e12 to 1e12 years

Very large years (|y|>1e13) cause infinite loop, and since nobody
needs time 100 times larger than the age of the universe anyways,
this constrains it to 1e12.

Following suggestion by @axil:
https://github.com/pyqtgraph/pyqtgraph/pull/1154#issuecomment-612662168

* Also catch ValueErrors occuring on Linux before OverfloeErrors

While zooming out, before hitting OverflowErrors, utctimestamp
produces ValueErrors (at least on my Linux machine), so they
are also catched.

* Fix: Timestamp 0 corresponds to year 1970

For large years, x axis labels jump by 1970 years if it is not
accounted for timestamp 0 to be equal to year 1970.

* Fix: When zooming into extreme dates, OSError occurs

This commit catches the OSError like the other observed errors

* Disable stepping below years for dates outside *_REGULAR_TIMESTAMP

2 reasons: First: At least on my Linux machine, zooming into
those dates creates infinite loops. Second: Nobody needs
sub-year-precision for those extreme years anyways.

* Adapt zoom level sizes based on current font size and screen resolution

This is somewhat experimental. With this commit, no longer 60 px are
assumed as width for all zoom levels, but the current font and
display resolution are considered to calculate the width of ticks in
each zoom level. See the new function `updateZoomLevels` for
details.
Before calling this function, overridden functions `paint` and
`generateDrawSpecs` provide information over the current display
and font via `self.fontScaleFactor` and `self.fontMetrics`.

* Meaningful error meassage when adding axis to multiple PlotItems

As @axil noted in the DateAxisItem PR, currently users get a
segmentation fault when one tries to add an axis to multiple
PlotItems. This commit adds a meaningful RuntimeError message
for that case.

* setZoomLevelForDensity: Refactoring and calculating optimal spacing on the fly

* DateTimeAxis Fix: 1970 shows when zooming far out

* Refactoring: Make zoomLevels a customizable dict again

* updated the dateaxisitem example

* Fix: Get screen resolution in a way that also works for Qt 4

This is both a simplification in code and an improvement in backwards compatibility with Qt 4.

* DateAxisItem Fix: Also resolve time below 0.5 seconds

* unix line endings in examples

* DateTimeAxis Fix: For years < 1 and > 9999, stepping broke

Stepping was off by 1970 years for years < 1 and > 9999,
resulting in a gap in ticks visible when zooming out. Fixed by
subtracting the usual 1970 years.

* DateTimeAxis Fix: Zooming out too far causes infinite loop

Fixed by setting default limits to +/- 1e10 years. Should still
be enough.

* improved second dateaxisitem example

* 1..9999 years limit

* DateTimeAxis: Use OrderedDict to stay compatible with Python < 3-6

* DateAxisItem: Use font height to determine spacing for vertical axes

* window title

* added dateaxisitem.rst

* updated index.rst

Co-authored-by: Lukas Heiniger <lukas.heiniger@sed.ethz.ch>
Co-authored-by: Lev Maximov <lev.maximov@gmail.com>
Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-04-27 11:43:22 -07:00
..
cx_freeze Added cx_freeze example (thanks Jerry!) 2014-06-06 15:53:17 -06:00
optics workaround pyside bug #671 2018-05-23 21:12:16 -07:00
py2exe Fix: avoid importing py3 module from pyqt when using py2 2014-04-03 13:33:16 -04:00
relativity Fix QString handling 2018-06-22 17:31:58 -07:00
verlet_chain Fix verlet integration demo 2017-10-18 00:18:46 -07:00
__init__.py fixed import statements python3 compatibility 2013-04-29 08:13:28 -04:00
__main__.py Intercept light/dark modes transitions on MacOS. 2020-03-08 10:34:54 +01:00
Arrow.py In ArrowItem allow individual parameter change through setStyle call. 2014-01-31 23:00:18 -05:00
BarGraphItem.py Added BarGraphItem.shape() to allow better mouse interaction 2014-02-09 10:38:29 -05:00
beeswarm.py merged many changes from acq4 2013-03-26 13:46:26 -04:00
CLIexample.py python3 fixes 2013-02-24 23:09:03 -05:00
ColorButton.py python3 fixes 2013-02-24 23:09:03 -05:00
ConsoleWidget.py python3 fixes 2013-02-24 23:09:03 -05:00
contextMenu.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
crosshair.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
customGraphicsItem.py python3 fixes 2013-02-24 23:09:03 -05:00
CustomGraphItem.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
customPlot.py Date axis item (#1154) 2020-04-27 11:43:22 -07:00
DataSlicing.py Added pg.gaussianFilter, removed all dependency on gaussian_filter 2014-03-11 19:01:34 -04:00
DataTreeWidget.py Cleanup, better support for tracebacks in DataTreeWidget 2014-09-25 15:21:28 -04:00
DateAxisItem_QtDesigner.py Date axis item (#1154) 2020-04-27 11:43:22 -07:00
DateAxisItem_QtDesigner.ui Date axis item (#1154) 2020-04-27 11:43:22 -07:00
DateAxisItem.py Date axis item (#1154) 2020-04-27 11:43:22 -07:00
designerExample_pyside2.py Fix up Qt.py and deprecate USE_XX variables 2018-02-16 20:42:34 -08:00
designerExample.py Added Qt.loadUiType function for PySide 2013-12-17 21:23:37 -05:00
designerExample.ui Added Qt.loadUiType function for PySide 2013-12-17 21:23:37 -05:00
DiffTreeWidget.py Added DiffTreeWidget 2014-09-25 17:26:06 -04:00
dockarea.py minor cleanups 2014-05-08 09:50:26 -04:00
Draw.py python3 fixes 2013-02-24 23:09:03 -05:00
ErrorBarItem.py Add ErrorBarItem.setData 2014-06-27 10:55:55 -04:00
exampleLoaderTemplate_pyqt5.py Fix up Qt.py and deprecate USE_XX variables 2018-02-16 20:42:34 -08:00
exampleLoaderTemplate_pyqt.py Fix up Qt.py and deprecate USE_XX variables 2018-02-16 20:42:34 -08:00
exampleLoaderTemplate_pyside2.py Fix up Qt.py and deprecate USE_XX variables 2018-02-16 20:42:34 -08:00
exampleLoaderTemplate_pyside.py Fix up Qt.py and deprecate USE_XX variables 2018-02-16 20:42:34 -08:00
exampleLoaderTemplate.ui Fix up Qt.py and deprecate USE_XX variables 2018-02-16 20:42:34 -08:00
FillBetweenItem.py Fix some bugs in PyQt5 2015-01-17 00:21:33 +08:00
Flowchart.py Clean up examples / docs 2016-08-31 15:14:25 -07:00
FlowchartCustomNode.py Fix opt name for SpinBox: range -> bounds. 2016-04-11 21:05:21 -07:00
fractal.py add reduce import to fractal demo 2018-03-29 08:49:42 -07:00
GLBarGraphItem.py Added GLBarGraphItem example 2013-09-06 15:36:36 -04:00
GLImageItem.py examples: use integer division in indexing 2018-03-30 14:51:29 -04:00
GLIsosurface.py python3 fixes 2013-02-24 23:09:03 -05:00
GLLinePlotItem.py Fixed GLLinePlotItem line width option 2013-03-30 22:39:11 -04:00
GLMeshItem.py Allow GLMeshItem to draw edges from MeshData with face-indexed vertexes. 2014-03-10 23:04:10 -04:00
GLScatterPlotItem.py python3 fixes 2013-02-24 23:09:03 -05:00
GLshaders.py python3 fixes 2013-02-24 23:09:03 -05:00
GLSurfacePlot.py Added pg.gaussianFilter, removed all dependency on gaussian_filter 2014-03-11 19:01:34 -04:00
GLViewWidget.py python3 fixes 2013-02-24 23:09:03 -05:00
GLVolumeItem.py python3 fixes 2013-02-24 23:09:03 -05:00
GradientEditor.py - Major reorganization; we now follow the standard python package structure. 2012-12-26 17:51:52 -05:00
GradientWidget.py Fix some bugs in PyQt5 2015-01-17 00:21:33 +08:00
GraphicsLayout.py python3 fixes 2013-02-24 23:09:03 -05:00
GraphicsScene.py - Major reorganization; we now follow the standard python package structure. 2012-12-26 17:51:52 -05:00
GraphItem.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
hdf5.py Import from python2_3 for all uses of basestring, cmp, and xrange 2015-05-19 09:29:55 -04:00
histogram.py Add 'fillOutline' option to draw an outline around a filled area (#999) 2019-08-17 09:57:40 -07:00
HistogramLUT.py Update histogramlut example to allow rgb mode 2017-09-26 08:50:31 -07:00
imageAnalysis.py Add image hover callback to imageAnalysis example 2018-07-07 00:10:15 -07:00
ImageItem.py python3 fixes 2013-02-24 23:09:03 -05:00
ImageView.py Clean up examples / docs 2016-08-31 15:14:25 -07:00
infiniteline_performance.py infinite line performance improvement 2016-02-04 03:28:59 +01:00
InfiniteLine.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
initExample.py Fix up Qt.py and deprecate USE_XX variables 2018-02-16 20:42:34 -08:00
isocurve.py examples: use integer division in indexing 2018-03-30 14:51:29 -04:00
JoystickButton.py python3 fixes 2013-02-24 23:09:03 -05:00
Legend.py Added symbol to Legend example 2014-01-18 23:30:03 -05:00
linkedViews.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
logAxis.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
LogPlotTest.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
MouseSelection.py Corrected mouse clicking on PlotCurveItem - now uses stroke outline instead of path shape 2013-12-19 09:56:58 -05:00
MultiplePlotAxes.py AxisItem bugfix: corrected x-linked view update behavior 2013-03-19 11:49:10 -04:00
multiplePlotSpeedTest.py Import from python2_3 for all uses of basestring, cmp, and xrange 2015-05-19 09:29:55 -04:00
MultiPlotSpeedTest.py Refactor MultiPlotSpeedTest.py 2018-02-03 11:01:03 +08:00
MultiPlotWidget.py Declare scipy optional (#1067) 2019-11-12 09:02:08 -08:00
multiprocess.py Fixed print statements for python 3 2013-01-12 14:35:32 -05:00
optics_demos.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
PanningPlot.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
parallelize.py Import from python2_3 for all uses of basestring, cmp, and xrange 2015-05-19 09:29:55 -04:00
parametertree.py more examples working under pyqt5 2015-02-28 11:05:57 -05:00
PlotAutoRange.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
PlotSpeedTest.py python3 fixes 2013-02-24 23:09:03 -05:00
Plotting.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
PlotWidget.py Merge branch 'pyqt5' into develop 2015-02-28 11:46:41 -05:00
ProgressDialog.py Prevent dialog from moving label/bar widgets on resize when nested 2017-10-04 09:01:51 -07:00
relativity_demo.py Added new demos: 2014-05-22 01:22:12 -04:00
RemoteGraphicsView.py Bugfixes: 2013-11-06 23:14:27 -05:00
RemoteSpeedTest.py python3 fixes 2013-02-24 23:09:03 -05:00
ROIExamples.py minor fixes 2018-06-15 14:18:38 -07:00
ROItypes.py Replaced usage of deprecated ROI classes in example (#946) 2019-06-21 21:19:02 -07:00
ScaleBar.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
ScatterPlot.py Add an example of using text strings as a custom smbol in ScatterPlotItem 2018-01-29 21:18:26 -05:00
ScatterPlotSpeedTest.py Fix up Qt.py and deprecate USE_XX variables 2018-02-16 20:42:34 -08:00
ScatterPlotSpeedTestTemplate_pyqt5.py flip template line endings 2018-05-24 08:54:31 -07:00
ScatterPlotSpeedTestTemplate_pyqt.py Many minor updates: 2012-10-02 21:23:59 -04:00
ScatterPlotSpeedTestTemplate_pyside2.py flip pyside2 template line endings 2018-05-17 09:02:41 -07:00
ScatterPlotSpeedTestTemplate_pyside.py Many minor updates: 2012-10-02 21:23:59 -04:00
ScatterPlotSpeedTestTemplate.ui Many minor updates: 2012-10-02 21:23:59 -04:00
ScatterPlotWidget.py Fix py3 string handling in scatterplotwidget example 2018-05-09 10:56:01 -07:00
scrollingPlots.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
SimplePlot.py Merge branch 'viewbox_limits' into develop 2014-02-04 20:32:44 -05:00
SpinBox.py Add example and test demonstrating spinbox bug 2018-01-24 09:11:42 -08:00
Symbols.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
syntax.py Dark mode support. 2020-03-07 23:02:40 +01:00
TableWidget.py TableWidget updates: 2013-03-06 06:27:24 -05:00
template.py Fix some bugs in PyQt5 2015-01-17 00:21:33 +08:00
test_examples.py Skip tests involving loadUi with pyside2 5.14 2020-02-24 23:00:42 -08:00
text.py Fixed TextItem briefly drawing with incorrect transform. 2016-09-14 18:18:33 -07:00
TreeWidget.py python3 fixes 2013-02-24 23:09:03 -05:00
utils.py Date axis item (#1154) 2020-04-27 11:43:22 -07:00
verlet_chain_demo.py corrections to manifest 2014-12-23 15:55:52 -05:00
VideoSpeedTest.py Fix UnboundLocalError in VideoSpeedTest. 2019-09-13 01:07:57 -04:00
VideoTemplate_pyqt5.py add missing example template file 2016-11-04 22:47:10 -07:00
VideoTemplate_pyqt.py Fix VideoSpeedTest to disable RawImageGLWidget when openGL is unavailable 2016-10-26 09:26:01 -07:00
VideoTemplate_pyside2.py flip pyside2 template line endings 2018-05-17 09:02:41 -07:00
VideoTemplate_pyside.py Fix VideoSpeedTest to disable RawImageGLWidget when openGL is unavailable 2016-10-26 09:26:01 -07:00
VideoTemplate.ui Fix VideoSpeedTest to disable RawImageGLWidget when openGL is unavailable 2016-10-26 09:26:01 -07:00
ViewBox.py Fix line width in a few examples 2015-02-28 11:26:45 -05:00
ViewBoxFeatures.py Replace deprecate class in examples 2018-02-16 12:21:39 +08:00
ViewLimits.py Removed duplicate limit-setting arguments 2014-01-31 13:04:47 -05:00