Repository navigation
Convert axis limit units in Qt plot options widget - #19677
Conversation
There was a problem hiding this comment.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Previously axis limits were converted to floats regardless of the actual value type in Qt backend's plot options widget. This commit makes datetime axis limits get converted to actual datetime values which are considerably easier to edit. Also, the methods used to convert the datetime values back have different names under PySide2 and PyQt. Previously the options widget was using the methods provided by PyQt only. We now support both Qt bindings. Re #19075
|
I don't use this widget, but this seems to be quite heavily leaning on special casing. Can you do something with the generic unit machinery? |
This was discussed in the issue (#19075) and to my understanding there was a weak consesus of doing it this way in the absence of general unconverter. I understand the |
|
|
||
|
|
||
| @pytest.mark.backend('Qt5Agg', skip_on_importerror=True) | ||
| def test_form_widget_get_with_date_field(): |
There was a problem hiding this comment.
I would merge this test with the one above to avoid paying twice for the setup of the widget.
| widget = _formlayout.FormWidget(form) | ||
| widget.setup() | ||
| values = widget.get() | ||
| assert(values == [datetime(year=2021, month=3, day=11)]) |
There was a problem hiding this comment.
assert needs no parentheses (it's not a function).
There was a problem hiding this comment.
True. Thanks for the heads up!
|
anyone can merge postci |
PR Summary
Qt backend's plot options widget converts axis limits to floats regardless of the actual data type. If the axes use e.g. datetime values, this makes editing the axis limits next to impossible.
This tries to solve the problem at least for datetime values by converting them to a proper type that can be shown in
QDateTimewidget. The solution is probably not ideal as discussed in the issue but at least it helps users that regularly use datetime X axis a lot.Resolves #19075
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).