* example app now workw with Qt4 and Python2 again
* Example App is now part of the test suite
* Add initExample
* No scary warning when launching examples
* Fix scary examples.__main__ warning
* Use courier new font as its on all platforms
* Remove commented out code
* Add newline
* Updated docs, example app now tested
* Non-relative import for example app
* Proper importing now
* dynamic range limiting in PlotDataItem
* revised version of cynamic range limiting
* replaced == with is operator
* removed unicode +- character, converted to ascii
* code/docstring cleanup
* clean state with changes
* silenced numpy all-NaN warnings
* reverted PlotWidget.py to original
* reverted PlotWidget.py to original
* reverted PlotWidget.py to original
* rewrapped/reformated setDynamicRangeLimits docstring
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
* LegendItem: Enable customization of label text size and tests
* One more CI
* Remove deleteLater of QAPP in legend item test
* Remove assert statement in setLabelTextSize
* Modify legend test without assertion
* Add a docs build job to CI
* Add sphinxopts to fail on warning
* Test sphinx warning
* Redid ci stage conditionals
* update conf.py to remove deprecation warning
* introduce 3rd stage for proper conditionals
* Attempt to fix malformed table
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
This commit adds a depth buffer in renderToArray().
This fixes the issue that overlapping objects are rendered incorrectly
when using renderToArray() on a GLViewWidget.
This might be related to issue #743.
* Add "lstep" and "rstep" step Modes
stepMode is currently either True or False. If it is True,
it requires the user to make len(x) = len(y)+1. This is
inconvenient because it makes it difficult to change the
stepMode on a given curve (just as one would change, e.g.,
its color).
This commit extends the current situation by introducing
two more step modes: "lstep" and "rstep", which do not require
passing an extra x value. In turn, this modes associate each
y value to either the left or the right boundary of the step.
For example, the "rstep" mode is handy when plotting "life"
digital signals in which x,y data pairs are appended as they
are read.
This commit does not modify the behaviour in case of stepMode=True
* Replace step mode names: lstep,rstep -> left,right
* Improve docs for stepMode
Reword docstring and add it to PlotDataItem class too
* Document left and right stepModes as added in v 0.12.0
TODO: confirm the exact version number to use here
* Add comments stress the need for "is True"
Some conditional statements in the code regarding stepMode are
done with "is True". This is actually required since other
possible values such as "left" also evaluate as true but should
not be caught.
* Deprecate boolean API for stepMode
Introduce stepMode="mid" as a replacement of stepMode=True,
but keeping full backwards compatibility with the old API.
Adapt docs, examples and tests accordingly.
* Raise ValueError on unsupported stepMode values
* Rename "mid" step mode to "center"
* Remove "added in 0.12.0" note
See https://github.com/pyqtgraph/pyqtgraph/pull/1360#discussion_r502746919
* Add deprecation warning when stepMode=True
Issue a DeprecationWarning if stepMode=True is being passed to the
constructor or setData() of PlotDataItem or PlotCurveItem.
Note: warnings module is imported locally so that it is esier to
remove once this check is no longer needed.
* Fix wrong syntax in last commit
Fix usage of "default" kwarg in dict.get()
* SignalProxy: Correct initialization without slot argument and provide tests
* Add missing slot is None case on disconnect
* Start new tests
* Exception block
* Test no module
* Different signal
* Debugging the signal connect
* Re initialize proxy after disconnect
* Add more test cases for blockSignal
* Change test case for signal count
* Give up for python 2 and pyside
* Exclude for Python 2.7 and PySide
* Convert float to integers in timer start period
This is something we're overriding in Orange3 (biolab/orange3#5007), as we change the symbols' alpha_value to show selected symbols. The default + and x symbols are too thin to show a noticeable change in alpha_value.
But I thought you might agree that the symbols look nicer this way.
* Fix PlotItem.setAxisItems
- Use extend so visibleAxes remains a flat list.
- More robust logic for detecting adding an AxisItem instance to
mulitple plots and suggest a workaround in the error message.
* Simplify membership check
* Add test for PlotItem setAxisitem logic
- avoid extra work when setLabelAngle would have no effect
- fix errors from bad parent transform (usually the displaying widget has not been given a size yet)
- add fileno method since console occludes sys.stdout
- fix editor spawning
- don't store sys.stdout, since this is not guaranteed to be the real stdout
* Exposed ability to set pens for handles and hovering for ROIs
* Consistent color format for pen creation
* Exposed ability to set pens for handles and hovering for ROIs
* Consistent color format for pen creation
* Add handleHoverPen arg to ROI and rename Handle arg to hoverPen
Co-authored-by: nmearl <nchlsearl@gmail.com>
* Handle axis SI prefix scaling in MatplotlibExporter
* Added some MatplotlibExporter tests and added matplotlib to CI deps
* Install mpl with pip instead of conda
* Cleanup
* make imageView-timeline unmovable
* imageview.timeline now visible over white background
* activate splitter when roi visible
* Re-add roiCurves
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
* checkOpenGLVersion exception for OpenGL ES
* checkOpenGLVersion exception
* checkOpenGLVersion exception
* python 2/3 compatibility
* Refactoring checkOpenGLVersion
Since the original goal of `checkOpenGLVersion` is to re-throw an exception or notify the user about a wrong OpenGL version in another exception, this commit unifies the two exception messages from `checkOpenGLVersion`.
Further, it corrects ">" to ">=" in the error message (originally my fault).
And it corrects verNumber to be an integer and not a boolean (there was a " < 2" too much at the end of the line).
Finally, since the opportunity was there, the method is further refactored, comments and a docstring are added.
Co-authored-by: 2xB <2xb@users.noreply.github.com>
* NEW options for LegendItem
* * changed 'drawFrame' into 'frame'
* added **kwargs to plotItem.addLegend
* added (frame=False, colCount=2) in legend example
* more elegant solution for legend.getLabel
* repaired getLabel
ItemSample.item == plotitem
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
* Added arrow symbols for the ScatterPlotItem
* Fixed arrows rotation in scatter plots
* Added new symbols to example
Co-authored-by: Miguel Sánchez de León Peque <msdeleonpeque@gmail.com>
Although the documentation used to say that specifying tipAngle would
override headWidth, headWidth was never used. The new behaviour is that
tipAngle will be used, with a default value of 25, unless headWidth is
specified.
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
- Adds doc strings for user-facing methods so they appear in the
documentation.
- Allows PlotItem.addLegend to accept the same arguments as LegendItem
constructor for convenience.
- Fixes a bug for adding a BarGraphItem (which doesn't have an antialias
option) to LegendItem
This issue was introduced in merging develop into #1175.
While refactoring for the merge, the change in namespace was not
correctly attributed, leading to the parameter `opts` to be assumed
in local namespace when it isn't.
* Do not wrap PlotView/ImageView
There is no need to wrap PlotView/ImageView into QMainWindow, since
only purpose of the QMainWindow is some default menu toolbar & menu
handling, that is not used by PyQtGraph anyway.
Moreover, every parent-less Qt widget can become window, so this
change just use PlotView/ImageView as windows, removing extra
complexity, eg. method forwarding, self.win property.
Another benefit of this change, it that these windows get initial
dimensions and titles as they were designed in .ui file.
* Properly cleanup on ImageView.close()
We should not close explicitly child widgets or clear scene, otherwise
Qt will deallocate children views, and cause "wrapped C/C++ object of
type ImageItem has been deleted" error next time we call close()
and/or some other methods.
All children, including self.ui.roiPlot, self.ui.graphicsView will be
closed together with its parent, so there is no need to close them
explicitly.
So the purpose of close it to reclaim the memory, but not to make the existing ImageView object dysfunctional.
* Remove references to plot & image windows after close
PyQtGraph images and plots module list variables are currently holding
references to all plots and image windows returned directly from main
module. This does not seem to be documented however, and causes the Qt
windows to be not released from memory, even if user releases all own
references.
This change removes the references from images/plots list once window
is closed, so when there is no other reference, window and all related
memory is reclaimed.
* Change all UI forms title from Form to PyQtGraph
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
* changed structure to redefine axis via
plotitem.setAxes
* cleanuup
* remove old axesitems before adding new ones
* DEBUGGED plotitem.setAxes
NEW AxisItem.setOrientation (needed by plotitem.setAxes)
show/hide right axes after .setAxes()
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
* Fix duplicate menus in GradientEditorItem
Add call to ev.accept in Tivk.mouseClickEvent to prevent parent menu from opening on a right click of a Tick.
Co-authored-by: Ogi <ognyan.moore@gmail.com>
Add a check in the viewTransformChanged function to only force a rerender when the downsampling factor changed.
Previously simply moving the image around or zooming in/out without changing the downsampling factor would force a complete rerendering of the image, which was very slow with large images. This way, the expensive rerender is only forced if necessary.
* Check and enforce view limits in the setRange function
* Check limits when setting aspectRatio
- This change is required due to moving the limit checking out of the updateViewRange function.
- If the original logic remained, aspect ratio could be lost due to "squshing" the requested view into the viewBox
* Add tests for ViewBox zooming limits and aspect ratio
* - Move test code to proper location and fix instantiation of QApplication
Co-authored-by: Israel Brewster <ijbrewster@alaska.edu>
* Fix: Parameter tree ignores user-set 'expanded' state
When setting the 'expanded' state of parameters, this change is not applied
in the graphically visible tree. This commit changes that behaviour by
adding a clause in `ParameterItem.optsChanged` to react to that.
Fixes#1130
* ParameterTree: Add option to synchronize "expanded" state
As seen in #1130, there is interest in synchronizing the "expanded" state
of `Parameter`s in `ParameterTree`s. As a default, this would lead to
users being forced to always have multiple `ParameterTree`s to be
expanded in the exact same way. Since that might not be desirable, this
commit adds an option to customize whether synchronization
of the "expanded" state should happen.
* Fix: Sync Parameter options "renamable" and "removable" with ParameterTrees
Currently, `Parameter` options `renamable` and `removable` are only considered
when building a new `ParameterTree`. This commit makes changes in those
options reflected in the corresponding `ParameterItem`s.
* ParameterTree: Reflect changes in Parameter option 'tip'
* Parameter: When setting "syncExpanded", update "expanded" state directly
Co-authored-by: 2xB <2xB@users.noreply.github.com>
Always pass `sys.argv`, if non-empty, to `QApplication` constructor.
This allows code to continue to rely on the fact that the application
name is by default set from `sys.argv[0]`, which is important for
example on Linux where this determines the WM_CLASS X attribute used by
desktop environments to match applications to their launchers.
If `sys.argv` is empty, as it is in an interactive Python session, pass
`["pyqtgraph"]` in its place as a sensible default for the application
name, which causes issues if not set (issue #1165).
If a `name` is given, set it using `setApplicationName()` instead of via
the argument list. This ensures it will be set even if the singleton
`QApplication` already existed prior to calling `mkQApp()`.
* Added test_AxisItem by @mliberty1
As found in https://github.com/pyqtgraph/pyqtgraph/pull/917
* test_AxisItem: Fit to current implementation
* DateAxisItem: Fix documentation to zoomLevels
zoomLevels is not intended to be set by the user (see discussion in converstation from
https://github.com/pyqtgraph/pyqtgraph/pull/1154/files#diff-aefdb23660d0963df0dff3a116baded8
). Also, `zoomLevelWidths` does currently not exist.
This commit adapts the documentation to reflect that.
* DateAxisItem: Do not publish ZoomLevel
* DateAxisItem testing: Removed unnecessary monkeypatch fixture
Co-authored-by: 2xB <2xB@users.noreply.github.com>
To set the tick font of `AxisItem`s, there are two options:
`setStyle({"tickFont":...})` and `setTickFont(...)`.
The first option sets `AxisItem.style['tickFont']`, the second
sets `self.tickFont`. Only `self.tickFont` is actually used.
This PR replaces all occurrences of the second variable with the first
variable, so both options work again. Also, documentation from
`setStyle` is copied to `setTickFont`.
Co-authored-by: 2xB <2xB@users.noreply.github.com>
* remote legacy work-around for old numpy errors
* forgot to remove the numpy_fix import
* require numyp >= 1.8.0
* improve performance of updateData PlotCurveItem (saves about 2us per call)
* improve ScatterPlotItem performance
* 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>
Items added to a `GraphicsLayout` only learn their size information
after the internal `QGraphicsGridLayout` recalculates the layout.
This is happening as a slot in the Qt event queue.
Not having updated geometry bounds directly after adding an item
leads to multiple issues when not executing the Qt event loop
in time (see below). This commit fixes that by always calling
`layout.activate()` after adding items, updating item sizes
directly.
This is a follow-up to PR #1167, where introducing a direct call to
`processEvents` was suspected to be able to cause side effects.
Notifying @j9ac9k and @campagnola, as they were involved in #1167.
Fixes#8Fixes#1136
`ParameterItem` handles visibility changes in `optsChanged`.
`GroupParameterItem` overrides this function, but never calls
the super function, leading in visibility changes not being
applied. This PR fixes this by calling said function.
Fixes#788
Fixes a bug where `setPen`, `setBrush` and `setLabelTextColor` would fail because they call `LegendItem.paint` without a pen. They should instead call `LegendItem.update`.
* More customizable and nicer legend.
- Give kwargs for legend frame and background colors instead of hard-coded values.
- Reduce spacing for more compact legend
- Give separate kwarg `labelTextColor`.
- New method to clear all legend items.
- New methods to get and change `offset` relative to the legend's parent.
- Horizontal instead of tilted lines for legend pictures.
* HDF5Exporter handles ragged curves by saving them into different datasets based on their names.
* Add HDF5Exporter tests
* Document HDF5Exporter
* Fix tmp file path
* py3k: Remove reduce calls.
* py3k: Remove compatibility sortList function.
Sorting by key has existed since Python 2.4.
* Remove unnecessary sys.path manipulation.
This file doesn't have any __main__ code to run anyway.
* Use context manager
* Fix HistogramLUTWidget with background parameter
HistogramLUTWidget cannot be initialized with the `background` parameter, because all parameters are also passed to the constructor of HistogramLUTItem which does not have a `background` parameter. This pull request fixes that issue by defining `background` explicitly as parameter in the function header.
Closes#175
* Added test for HistogramLUTWidget initialization with background
* Fixed Python2 compatibility
* Do not pg.exit() after test
* Moved test_histogramlutwidget to widget tests
* Always update transform when setting angle of a TextItem
* Add test to check TextItem.setAngle
* Relax test a bit but still check that setAngle has an effect
* Add docstring to setAngle
* Remove unneeded numpy testing function imports
In lines 174 and 191 cev[0] is being accessed when cev is an empty list. I get this error when inheriting from GraphicsLayoutWidget and overloading mouseDoubleClickEvent.
* Make QWheelEvent code consistently compatible with Qt5
* Add documentation
* Removed old TODO message
* Init remote QWheelEvent only with relative position, minor code simplifications
* RemoteGraphicsView Renderer assumes to be at (0,0)
* Orientation serialized as boolean
* Fix: Item on ViewBox causes duplicate paint calls
* Assure call of ViewBox.updateMatrix on resizeEvent
* Fix: Disable autorange on "ViewBox.setRange" before updateAutoRange is called
(Called via updateViewRange -> update -> prepareForPaint)
* adding option to set grid color on demand
* Update after setColor
* Made GLGridItem color attribute private
* Init GLGridItem color with fn.Color
* Added docstring
* Warn if visible window is garbage collected
* (Py)Qt does not rely on Python GC
* Only warn if deleted widget has no parents (if it is a standalone window)
* Hide windows when closing
* Only implement GraphicsView.__del__ if it does not prevent circular reference garbage collection
Basically, profiling has pointed me to the fact that a fair bit of code time is spent in `setShadowPen()` (actually, it's in `mkPen()`, which `setShadowPen()` calls), even when no shadow pen is specified.
In my application, I'm calling `pyqtgraph.PlotDataItem.setdata()`, which calls through PlotDataItem->setData, PlotDataItem->updateItems. At some point in the call stack, the default value for `shadowPen` is being inserted into the kwargs, which then causes the specious calling of setShadowPen.
Anyways, if we check if shadowPen is a value other then none, this doesn't happen.
Currently `_updateMaxTextSize ` will increase the current space required for axis labels, if necessary, but not decrease it when the extra space is no longer needed. The proposed change will release no longer needed space again.
* FIX: Exception.message does not exist in Python3
* FIX: Allow multiline configfile parameters
* Added configparser tests
* Reasonable file ending for test files
Before, if the path contained escaped sequences, they would be parsed before being written to `reload_test_mod.py`, therefore when the file was parsed by the Python interpreter, the escape signs would be missing. With this commit, the Python representation is written to the file, so escaped sequences stay escaped.
Issue #835 shows that comparing `bins`, which may be a numpy array, with a string `'auto'` leads to element-wise comparison, because the `==` operator for numpy arrays is used. With this commit, potential array and string are switched, so the `==` operator for strings is used, which does no element-wise comparison.
Pull request #907 addressed a specific case where a signal was emitted before a state update.
If an application's slot then calls back into the instance, the instance was in an inconsistent
state. This commit audits and fixes similar issues throughout the pyqtgraph library. This
commit fixes several latent issues:
* SignalProxy: flush -> sigDelayed -> signalReceived would have incorrectly resulted in timer.stop().
* ViewBox: resizeEvent -> sigStateChange -> background state
* ViewBox: setRange -> sigStateChange -> autoranging not updated correctly
* ViewBox: updateMatrix -> sigTransformChanged -> any _matrixNeedsUpdate = True -> ignored
* Parameter: Child may have missed state tree messages on insert or received extra on remove
* GraphicsView: updateMatrix -> sigDeviceRangeChanged/sigDeviceTransformChange -> before propagated to locked viewports.
E.g. when opening the Matplotlib exporter multiple times, and one closes one instance, Python crashes.
This is caused by the Matplotlib QMainWindow listening to the closeEvent and deleting the only reference of
the window before it is closed properly.
Do not assume that x-values have uniform spacing -- this can cause problems especially with large datasets and non-uniform spacing (e.g., time-dependent readings from an instrument).
Use `np.searchsorted` instead to find the first and last data index in the view range. This only assumes that x-values are in ascending order. This prevents potentially too strong clipping.