-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date axis item #1154
Merged
Merged
Date axis item #1154
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
da8c53d
Add DateAxisItem
3rdcycle b21dfc2
Change style to camelCase
3rdcycle 3816f4d
Fix missing first tick for negative timestamps
3rdcycle d627e39
Add ms precision, auto skipping
3rdcycle 83f53de
fixes suggested by @goetzc
606cae6
workaround for negative argument to utcfromtimestamp on windows
41f9e4f
attachToPlotItem method
4b3199c
default date axis orientation
4c2b865
Use new DateAxisItem in Plot Customization example
2xB 852f369
Merge pull request #1 from 2xB/2xb-date-axis-item-patch
axil 3ac98c2
attachToPlotItem bugfix
61222db
examples of DateAxisItem
c856f2c
modified description of customPlot example
64120e8
added descriptions to the new examples, reformatted their code, inclu…
55d1749
typo
ab756bd
Refactored code for setting axis items into new function
2xB 9e2e8d1
Fix string comparison with ==
2xB 2f9b4f7
Doc: Slightly more text for DateAxisItem, small improvement for PlotItem
2xB a35c6b6
Make PlotWidget.setAxisItems official
2xB 8a170f5
Fix typo in docstring
2xB e86bca7
Merge pull request #2 from 2xB/2xb-date-axis-item-patch2
axil 75978ef
renamed an example
3958dc9
Merge branch 'develop' into date-axis-item
axil 876b5a7
merge bug fix
b71cc0c
Revert "merge bug fix"
2xB a02af8e
Real bug fix
2xB 625f1f4
Merge pull request #4 from 2xB/2xb-date-axis-item-patch3
axil 24bcacd
support for dates upto -1e13..1e13
b58dfc2
Automatically limit DateAxisItem to a range from -1e12 to 1e12 years
2xB c5facf6
Also catch ValueErrors occuring on Linux before OverfloeErrors
2xB 9259e12
Fix: Timestamp 0 corresponds to year 1970
2xB 4703027
Fix: When zooming into extreme dates, OSError occurs
2xB db3fffd
Disable stepping below years for dates outside *_REGULAR_TIMESTAMP
2xB 67a5624
Merge pull request #5 from 2xB/2xb-date-axis-item-patch4
axil a4f8216
Adapt zoom level sizes based on current font size and screen resolution
2xB 58e32a5
Meaningful error meassage when adding axis to multiple PlotItems
2xB 3e14971
Merge pull request #7 from 2xB/2xb-date-axis-item5-meaningfulerror
axil e29b500
setZoomLevelForDensity: Refactoring and calculating optimal spacing o…
2xB 44dc901
DateTimeAxis Fix: 1970 shows when zooming far out
2xB ca69a5e
Refactoring: Make zoomLevels a customizable dict again
2xB 021aa11
Merge pull request #6 from 2xB/2xb-date-axis-item-adaptive-zoom
axil 0f6e9ef
updated the dateaxisitem example
15b8c7b
Fix: Get screen resolution in a way that also works for Qt 4
2xB 3d1af34
Merge pull request #8 from 2xB/2xb-date-axis-item6-backwards-compatib…
axil aa6d0cc
DateAxisItem Fix: Also resolve time below 0.5 seconds
2xB 577cc5f
unix line endings in examples
a494e9c
Merge pull request #9 from 2xB/2xb-date-axis-item7-zoomin-fix
axil 7c37c02
DateTimeAxis Fix: For years < 1 and > 9999, stepping broke
2xB b600961
DateTimeAxis Fix: Zooming out too far causes infinite loop
2xB 547cce8
improved second dateaxisitem example
98c0ed9
Merge pull request #10 from 2xB/2xb-date-axis-item9-fixlargeyears
axil 7c817a0
1..9999 years limit
e11b8e2
DateTimeAxis: Use OrderedDict to stay compatible with Python < 3-6
2xB 644d5e4
DateAxisItem: Use font height to determine spacing for vertical axes
2xB 1c191ef
Merge pull request #11 from 2xB/2xb-date-axis-item10-multiplefixes
axil ad598fd
window title
d08850f
added dateaxisitem.rst
8facdc4
updated index.rst
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
DateAxisItem | ||
============ | ||
|
||
.. autoclass:: pyqtgraph.DateAxisItem | ||
:members: | ||
|
||
.. automethod:: pyqtgraph.DateAxisItem.__init__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ Contents: | |
graphicsitem | ||
uigraphicsitem | ||
graphicswidgetanchor | ||
dateaxisitem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Demonstrates the usage of DateAxisItem to display properly-formatted | ||
timestamps on x-axis which automatically adapt to current zoom level. | ||
|
||
""" | ||
import initExample ## Add path to library (just for examples; you do not need this) | ||
|
||
import time | ||
from datetime import datetime, timedelta | ||
|
||
import numpy as np | ||
import pyqtgraph as pg | ||
from pyqtgraph.Qt import QtGui | ||
|
||
app = QtGui.QApplication([]) | ||
|
||
# Create a plot with a date-time axis | ||
w = pg.PlotWidget(axisItems = {'bottom': pg.DateAxisItem()}) | ||
w.showGrid(x=True, y=True) | ||
|
||
# Plot sin(1/x^2) with timestamps in the last 100 years | ||
now = time.time() | ||
x = np.linspace(2*np.pi, 1000*2*np.pi, 8301) | ||
w.plot(now-(2*np.pi/x)**2*100*np.pi*1e7, np.sin(x), symbol='o') | ||
|
||
w.setWindowTitle('pyqtgraph example: DateAxisItem') | ||
w.show() | ||
|
||
## Start Qt event loop unless running in interactive mode or using pyside. | ||
if __name__ == '__main__': | ||
import sys | ||
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): | ||
app.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Demonstrates the usage of DateAxisItem in a layout created with Qt Designer. | ||
|
||
The spotlight here is on the 'setAxisItems' method, without which | ||
one would have to subclass plotWidget in order to attach a dateaxis to it. | ||
|
||
""" | ||
import initExample ## Add path to library (just for examples; you do not need this) | ||
|
||
import sys | ||
import time | ||
|
||
import numpy as np | ||
from PyQt5 import QtWidgets, QtCore, uic | ||
import pyqtgraph as pg | ||
|
||
pg.setConfigOption('background', 'w') | ||
pg.setConfigOption('foreground', 'k') | ||
|
||
BLUE = pg.mkPen('#1f77b4') | ||
|
||
Design, _ = uic.loadUiType('DateAxisItem_QtDesigner.ui') | ||
|
||
class ExampleApp(QtWidgets.QMainWindow, Design): | ||
def __init__(self): | ||
super().__init__() | ||
self.setupUi(self) | ||
now = time.time() | ||
# Plot random values with timestamps in the last 6 months | ||
timestamps = np.linspace(now - 6*30*24*3600, now, 100) | ||
self.curve = self.plotWidget.plot(x=timestamps, y=np.random.rand(100), | ||
symbol='o', symbolSize=5, pen=BLUE) | ||
# 'o' circle 't' triangle 'd' diamond '+' plus 's' square | ||
self.plotWidget.setAxisItems({'bottom': pg.DateAxisItem()}) | ||
self.plotWidget.showGrid(x=True, y=True) | ||
|
||
app = QtWidgets.QApplication(sys.argv) | ||
app.setStyle(QtWidgets.QStyleFactory.create('Fusion')) | ||
app.setPalette(QtWidgets.QApplication.style().standardPalette()) | ||
window = ExampleApp() | ||
window.setWindowTitle('pyqtgraph example: DateAxisItem_QtDesigner') | ||
window.show() | ||
|
||
## Start Qt event loop unless running in interactive mode or using pyside. | ||
if __name__ == '__main__': | ||
import sys | ||
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): | ||
app.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QMainWindow" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>536</width> | ||
<height>381</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="PlotWidget" name="plotWidget"/> | ||
</item> | ||
</layout> | ||
</widget> | ||
<widget class="QMenuBar" name="menubar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>536</width> | ||
<height>18</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
</widget> | ||
<customwidgets> | ||
<customwidget> | ||
<class>PlotWidget</class> | ||
<extends>QGraphicsView</extends> | ||
<header>pyqtgraph</header> | ||
</customwidget> | ||
</customwidgets> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to point out #917 implements a similar feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Since having a seperate method to unlink is the type of implementation you suggested over there, I'd suggest to just borrow the unit tests from over there. If that is agreed on, I'd do that, since
unlinkFromView
was from me.