Commit Graph

94 Commits

Author SHA1 Message Date
njessurun c0eb3267d2 Remove python 2 code paths 2021-08-02 12:07:25 -04:00
Kyle Sunden a472f8c5de
Remove all usage of python2_3.py (#1939)
* Remove all usage of python2_3.py

Technically these functions were exported at the top level of the library, this removes them without warning... If we want to we can bring them back for there, but I honestly don't think its needed, as we are py3 only now and have been for multiple releases.

This may introduce a number of 'useless cast' or similar but those were always happening anyway

This PR brought to you by sed

* Update varname in hdf example to avoid collision with builtin

* Clean up some leftover comments surrounding imports of compat code

* Unnecessary string casts

* Additional unnecessary casts

* syntax error fix

* more unnecessary casts

* Yet more unnecessary casts
2021-08-01 21:43:32 -07:00
Nils Nemitz 8b4db67ae9 None-check self.label before access 2021-07-18 17:24:55 +09:00
Nils Nemitz 775f1d629c
Separate out mouse events stolen by AxisItem (#1845)
* separate out mouse events on main plot area

* work in scenepositions so that detection also works in a layout

* added comments/remove debug statements
2021-06-22 16:17:39 -07:00
Ogi Moore 195a1a6fa3 Remove Qt 6.0 support
Simplify some PyQt6 code branches
2021-06-08 21:23:49 -07:00
Ogi Moore d455da9aec Use Qt6 Enum Namespace
This namespace appears to be valid in PySide2/PyQt5 5.12+ so we may as
well migrate to the newer namespace ourselves.
2021-06-08 21:23:49 -07:00
Nils Nemitz 61f067bf7c
Add axis convenience methods and matrix display example (#1726)
* add axis convenient methods and matrix display example

* wrestled wayward space back into docstring

* color map names are case sensitive on Linux

* docstring fix for PlotItem

* protect AxisItem.linkToView from being obscured by DateAxisItem override

* replaced setOrigin method by promoted setPos and setScale

* made tri-state axes switching explicit

* reverted setRect behavior, documentation pass for ImageItem

* minor text adjustment

* implmented some suggested revisions

* fix input parsing for setRect and add tests so that I don't break it again

* don't try to re-add transform after clearing it

* changed example and doc image generators to pg.exec()

* removed commented-out code

* cleaned up transform eqaulity assertion

* restored devoured comment

* restored devoured comment
2021-06-07 07:44:19 -07:00
Ogi Moore 314121192a Use math module for isfinite or isnan for scalars
Various places in the library attempt to check if scalars are finite
via numpy methods, which are intended to be used on numpy arrays.  Using
the math module equivalent functions on scalars is significantly faster.

In a few places, I also use numpy methods explicitly (np.all vs. all)
2021-04-23 22:43:57 -07:00
Ogi Moore 85c726e49a Replace uses of np.log on scalers with math.log 2021-04-23 11:53:00 -07:00
Ogi Moore ff71b6be6b Add actual deprecation warnings 2021-02-11 21:34:02 -08:00
KIU Shueng Chuan 185f9c7dad remove scale, rotate and translate shims 2021-02-01 09:06:23 +08:00
KIU Shueng Chuan 0957735255 AxisItem.py : workaround or-ing of text flags 2021-01-23 08:29:52 +08:00
KIU Shueng Chuan b6e713c306 bug: AlignCenter should have been AlignHCenter
from the Qt documentation,
- "AlignCenter = AlignVCenter | AlignHCenter"
- "You can use at most one horizontal and one vertical flag at a time.
  Qt::AlignCenter counts as both horizontal and vertical"
- "Conflicting combinations of flags have undefined meanings"

for AxisItem.py, from the code structure, it would appear that the
intent was to use AlignHCenter.

for ROI.py, AlignCenter == AlignCenter | AlignVCenter
2021-01-19 09:45:56 +08:00
Matt Liberty a3fbd18239
Clipped AxisItem tick value labels to prevent drawing artifacts #732 (#1447) 2020-11-21 00:46:31 -08:00
Kenneth Lyons 1f76ac0e2c
Add a docs build job to CI (#1328)
* 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>
2020-10-15 08:43:23 -07:00
Dennis Göries 3b6eb02520
AxisItem: Account for empty strings in the visibility of text and units (#1367)
* Rebase

* make the tests work

* add test and rather more cleanup

* Cleanup for axisitem visibility test

* Another cleanup in test axis item
2020-10-14 20:40:54 -07:00
Ogi Moore 302d66dd67
Add tickAlpha to AxisItem Style Options (#1274)
* Add tickAlpha setting to AxisItem style

* reworking setTickAlpha docs, redo logic based on types

Co-authored-by: demonchild2112 <denverlovesyou@gmail.com>
2020-06-24 17:42:28 -07:00
Ogi Moore b8abd5d02e Don't let axis item reduce space 2020-06-24 15:40:01 -07:00
Ogi Moore a192707654 Implement PR403-diff 2020-06-22 23:02:48 -07:00
Ogi Moore 0c08adc411
Merge pull request #1257 from VesnaT/tickFont_painter
AxisItem: Make painter (tick) font dependent
2020-06-15 07:54:25 -07:00
Vesna Tanko ad4f796e32 AxisItem: Make painter tick font dependent 2020-06-15 11:03:50 +02:00
Ogi Moore cee27b6268 fix-incorrect-tick-text-boundaries-calculation 2020-06-12 22:28:26 -07:00
Ogi Moore 5b5749aa0b Revert "changed structure to redefine axis via plotitem.setAxes (#391)"
This reverts commit bb21791c71.
2020-06-07 20:29:28 -07:00
Karl Georg Bedrich bb21791c71
changed structure to redefine axis via plotitem.setAxes (#391)
* 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>
2020-06-01 11:12:52 -07:00
Paul Müller e08ac110f5
pretty-print log-scale axes labels (#1097)
* pretty-print log-scale axes labels

* only pretty-print in python 3
2020-05-30 13:53:38 -07:00
Ogi Moore 99c43613f3
Merge pull request #1174 from Ma-Shell/develop
Fixed a possible race condition with linked views
2020-05-29 23:00:10 -07:00
2xB 96be1bd23f
Fix: AxisItem tickFont is defined in two places while only one is used (#1180)
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>
2020-05-04 14:58:29 -07:00
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
Marcel Schumacher a697b5584a Fixed a possible race condition with linked views 2020-04-14 17:24:54 +02:00
Kenneth Lyons db67a256a9
Miscellaneous doc fixups (#1142)
* Miscellaneous doc cleanup

* Moved dockarea up a level (like flowchart, parametertree). Removed extraneous parametertree doc
2020-04-03 10:06:25 -07:00
Ogi 3158c5b4db Use int() instead of .__int__() 2020-02-29 14:38:19 -08:00
Ognyan Moore 6ed8a405fe Address FutureWarning about implicit float to int conversions 2020-02-28 14:27:10 -08:00
SamSchott c95ab570b1 set color of tick-labels separately (#841) 2019-11-19 20:43:27 -08:00
2xB 061a30e827 Correctly include SI units for log AxisItems (#972) 2019-09-12 21:58:49 -07:00
Jeffrey Nichols d9f0da5a7c
Fix for AxisItem using old scale to create label 2019-06-27 14:45:37 -04:00
Ogi Moore 053fca6e83
Revert "`_updateMaxTextSize` to reduce text size when no longer needed (#838)" (#957)
This reverts commit 0ba07300e1.
2019-06-23 21:41:20 -07:00
SamSchott 0ba07300e1 `_updateMaxTextSize` to reduce text size when no longer needed (#838)
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.
2019-06-23 18:10:35 -07:00
SamSchott 3e7cace746 tickSpacing bug fix (#836)
Fixed a bug where `tickSpacing()` would return `None` if `style['maxTickLevel'] < 2`, resulting in the axis not being drawn.
2019-06-23 17:27:16 -07:00
Janez Demšar 9b8ef188a5 Fix incorrect clipping of horizontal axis when stopAxisAtTick is set (#932)
Horizontal axis are clipeed incorrectly because the code always takes
the vertical coordinate of the span even if the axis is horizontal.
2019-06-19 22:07:57 -07:00
danielhrisca 82d2b757e4 speed up AxisItem __init__ 2019-01-18 10:32:10 +02:00
danielhrisca b575b56edf avoid calling setLabel repeatedly for AxisItem 2019-01-16 16:44:00 +02:00
Luke Campagnola 4285785985 Revert "Fixed AxisMouse drag issue"
The original change breaks mouse dragging directly on the axis

This reverts commit 9bfdda06a6.
2018-10-29 10:59:11 -07:00
Luke Campagnola 574c5f3a47
Merge pull request #565 from justengel/axis_mouse_drag
Fixed AxisItem mouse drag issue
2018-09-28 16:02:29 -07:00
Luke Campagnola 6b26245e50
Add explanatory comment 2018-09-28 16:02:14 -07:00
David Nadlinger fe7e1775da AxisItem: Fix tick elision with self.scale set
Previously, only the highest level ticks would be displayed
for e.g. scale = 1e3.
2018-07-11 15:31:29 +01:00
HashSplat 9bfdda06a6 Fixed AxisMouse drag issue
Issue where MouseDragEvent would only work for 1 AxisItem. Allowed the MouseDragEvent to propagate to other AxisItems. I had this issue by setting the ViewBox background color and changed the AxisItem ZValue to make the AxisItems visible which made the AxisItem receive all of the MouseDragEvents and only one Axis would actually allow dragging.
2017-09-20 17:15:54 -04:00
Luke Campagnola a7b0bbb3bb Fixed AxisItem ignoring setWidth when label is displayed 2014-08-29 22:50:14 -04:00
Luke Campagnola 753ac9b4c4 Squashed commit of the following:
commit ca3fbe2ff9
Author: Luke Campagnola <luke.campagnola@gmail.com>
Date:   Thu Aug 7 08:41:30 2014 -0400

    Merged numerous updates from acq4:
    * Added HDF5 exporter
    * CSV exporter gets (x,y,y,y) export mode
    * Updates to SVG, Matplotlib exporter
    * Console can filter exceptions by string
    * Added tick context menu to GradientEditorItem
    * Added export feature to imageview
    * Parameter trees:
        - Option to save only user-editable values
        - Option to set visible title of parameters separately from name
        - Added experimental ParameterSystem for handling large systems of
            interdependent parameters
        - Auto-select editable portion of spinbox when editing
    * Added Vector.__abs__
    * Added replacement garbage collector for avoiding crashes on multithreaded Qt
    * Fixed "illegal instruction" caused by closing file handle 7 on OSX
    * configfile now reloads QtCore objects, Point, ColorMap, numpy arrays
    * Avoid triggering recursion issues in exception handler
    * Various bugfies and performance enhancements
2014-08-07 09:03:26 -04:00
Luke Campagnola 74b5ba6f7e Add AxisItem.setTickSpacing() 2014-07-25 07:52:58 -04:00
Luke Campagnola 7b862f4f87 docstring indentation fix 2014-04-28 08:22:07 -04:00