Skip to content

Commit 9954426

Browse files
Merge branch 'doc/update-guiqwt-migration' into develop
2 parents 7d28ac9 + 52f5404 commit 9954426

6 files changed

Lines changed: 78 additions & 70 deletions

File tree

‎doc/dev/guiqwt_to_plotpy.csv‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ guiqwt v4,PlotPy v2,API changes
22
``guiqwt.events``,``plotpy.events``
33
``guiqwt.interfaces``,``plotpy.interfaces``
44
``guiqwt.io``,``plotpy.io``
5-
``guiqwt.io.eliminate_outliers``,*removed*
5+
``guiqwt.io.eliminate_outliers``,*removed*,"Use ``numpy.histogram``, ``plotpy.lutrange.hist_range_threshold`` and ``numpy.clip``"
6+
``guiqwt.config``,``plotpy.config``
7+
``guiqwt.transitional``,``qwt``,Import Qwt classes directly from the ``qwt`` package (PythonQwt)
8+
``guiqwt.signals``,*removed*,"Signals are attributes of the emitting classes (e.g. ``BasePlot.SIG_ITEM_REMOVED``)"
9+
``guiqwt.builder``,``plotpy.builder``
10+
``guiqwt.builder.PlotItemBuilder``,``plotpy.builder.PlotBuilder``,See `New options added to plot builder`_
11+
``guiqwt.panels``,``plotpy.panels``
612
``guiqwt.annotations``,``plotpy.items``
713
``guiqwt.curve``,``plotpy.items``
814
``guiqwt.image``,``plotpy.items``
@@ -13,20 +19,28 @@ guiqwt v4,PlotPy v2,API changes
1319
``guiqwt.histogram.hist_range_threshold``,``plotpy.lutrange.hist_range_threshold``
1420
``guiqwt.histogram.lut_range_threshold``,``plotpy.lutrange.lut_range_threshold``
1521
``guiqwt.histogram.ContrastAdjustment``,``plotpy.panels.contrastadjustment.ContrastAdjustment``
22+
``guiqwt.histogram.LevelsHistogram``,``plotpy.panels.contrastadjustment.LevelsHistogram``
1623
``guiqwt.image.get_items_in_rectangle``,``plotpy.items.get_items_in_rectangle``
1724
``guiqwt.curve.PlotItemList``,``plotpy.panels.itemlist.PlotItemList``
25+
``guiqwt.cross_section.CrossSectionWidget``,``plotpy.panels.csection.cswidget.CrossSectionWidget``
1826
``guiqwt.cross_section.XCrossSection``,``plotpy.panels.csection.cswidget.XCrossSection``
1927
``guiqwt.cross_section.YCrossSection``,``plotpy.panels.csection.cswidget.YCrossSection``
2028
``guiqwt.cross_section.ObliqueCrossSection``,``plotpy.panels.csection.cswidget.ObliqueCrossSection``
2129
``guiqwt.plot.PlotManager``,``plotpy.plot.PlotManager``
2230
``guiqwt.plot.CurveWindow``,``plotpy.plot.PlotWindow``,See `Generic PlotWidgets`_
23-
``guiqwt.plot.BaseImageWidget``,``plotpy.plot.BasePlotWidget``,See `Generic PlotWidgets`_
31+
``guiqwt.plot.ImageWindow``,``plotpy.plot.PlotWindow``,See `Generic PlotWidgets`_
32+
``guiqwt.plot.BaseImageWidget``,``plotpy.plot.plotwidget.BasePlotWidget``,See `Generic PlotWidgets`_
2433
``guiqwt.plot.CurveWidget``,``plotpy.plot.PlotWidget``,See `Generic PlotWidgets`_
25-
``guiqwt.plot.CurveWidgetMixin``,``*removed*``,See `Generic PlotWidgets`_
34+
``guiqwt.plot.ImageWidget``,``plotpy.plot.PlotWidget``,See `Generic PlotWidgets`_
35+
``guiqwt.plot.CurveWidgetMixin``,*removed*,See `Generic PlotWidgets`_
36+
``guiqwt.plot.ImageWidgetMixin``,*removed*,See `Generic PlotWidgets`_
2637
``guiqwt.plot.CurveDialog``,``plotpy.plot.PlotDialog``,See `Generic PlotWidgets`_
27-
``guiqwt.curve.CurvePlot``,``plotpy.plot.baseplot.BasePlot``,See `Generic PlotWidgets`_
28-
``guiqwt.curve.CurvePlot.canvas2plotitem``,*removed*
29-
``guiqwt.curve.CurvePlot.plotitem2canvas``,*removed*
38+
``guiqwt.plot.ImageDialog``,``plotpy.plot.PlotDialog``,See `Generic PlotWidgets`_
39+
``guiqwt.baseplot.BasePlot``,``plotpy.plot.BasePlot``
40+
``guiqwt.curve.CurvePlot``,``plotpy.plot.BasePlot``,See `Generic PlotWidgets`_
41+
``guiqwt.image.ImagePlot``,``plotpy.plot.BasePlot``,See `Generic PlotWidgets`_
42+
``guiqwt.curve.CurvePlot.canvas2plotitem``,``plotpy.coords.canvas_to_axes``,"``canvas2plotitem(item, x, y)`` becomes ``canvas_to_axes(item, QPointF(x, y))``"
43+
``guiqwt.curve.CurvePlot.plotitem2canvas``,``plotpy.coords.axes_to_canvas``,"``plotitem2canvas(item, x, y)`` becomes ``axes_to_canvas(item, x, y)``"
3044
``guiqwt.plot.SubplotWidget``,``plotpy.plot.SubplotWidget``
3145
``guiqwt.pyplot``,``plotpy.pyplot``
3246
``guiqwt.styles``,``plotpy.styles``
@@ -36,16 +50,17 @@ guiqwt v4,PlotPy v2,API changes
3650
``guiqwt.qthelpers.exec_image_save_dialog``,``plotpy.widgets.imagefile.exec_image_save_dialog``
3751
``guiqwt.qthelpers.exec_image_open_dialog``,``plotpy.widgets.imagefile.exec_image_open_dialog``
3852
``guiqwt.qthelpers.exec_images_open_dialog``,``plotpy.widgets.imagefile.exec_images_open_dialog``
39-
``guiqwt.qthelpers.mimedata2url``,*removed*
53+
``guiqwt.qthelpers.mimedata2url``,``guidata.qthelpers.mimedata2url``
4054
``guiqwt.scaler``,``plotpy.mathutils.scaler``
4155
``guiqwt.debug``,*removed*
4256
``guiqwt.debug.buttons_to_str``,``plotpy.events.buttons_to_str``
4357
``guiqwt.debug.evt_type_to_str``,``plotpy.events.evt_type_to_str``
4458
``guiqwt.debug.print_event``,*removed*
4559
``guiqwt.debug.qimage_format``,*removed*
4660
``guiqwt.debug.qimage_to_str``,*removed*
61+
``guiqwt.widgets.base``,``plotpy.widgets.basetransform``
4762
``guiqwt.widgets.fit``,``plotpy.widgets.fit``
48-
``guiqwt.widgets.rotatecrop``,``plotpy.widgets.rotatecrop``
4963
``guiqwt.widgets.fliprotate``,``plotpy.widgets.fliprotate``
64+
``guiqwt.widgets.resizedialog``,``plotpy.widgets.resizedialog``
5065
``guiqwt.widgets.rotatecrop``,``plotpy.widgets.rotatecrop``
5166
``guiqwt.qtdesigner``,``plotpy.widgets.qtdesigner``

‎doc/dev/guiqwt_to_plotpy.rst‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,16 @@ to the `Generic PlotWidgets`_ may require some minor adaptation of your code:
7070
pass ``except_grid=False`` to your
7171
:py:meth:`.BasePlot.del_all_items` calls.
7272

73-
* Some arguments were added to the constructor of the :py:class:`.BasePlot` class
74-
(the arguments of the constructors of the old classes ``CurvePlot`` and
75-
``ImagePlot`` have been merged): the new `type` of the plot
76-
(see `Generic PlotWidgets`_), and the arguments of the ``ImagePlot``
77-
constructor that the ``CurvePlot`` constructor missed : ``zlabel``, ``zunit``,
78-
``yreverse``, ``aspect_ratio``, ``lock_aspect_ratio`` and ``force_colorbar_enabled``.
79-
As a consequence, if you did not use keywords, but positional-only arguments when
80-
instantiating a ``CurvePlot`` or ``ImagePlot``, you should adapt the new calls to the
81-
:py:class:`.BasePlot` constructor to meet the new arguments list.
73+
* The constructor of the :py:class:`.BasePlot` class now only takes ``parent``
74+
and ``options`` arguments. The arguments of the constructors of the old classes
75+
``CurvePlot`` and ``ImagePlot`` (``title``, ``xlabel``, ``ylabel``, ``xunit``,
76+
``yunit``, ``gridparam``, ``section``, ``axes_synchronised``, ``zlabel``,
77+
``zunit``, ``yreverse``, ``aspect_ratio``, ``lock_aspect_ratio``) have been
78+
merged into the :py:class:`.BasePlotOptions` dataclass, together with the new
79+
``type`` (see `Generic PlotWidgets`_) and ``force_colorbar_enabled`` options.
80+
As a consequence, you should pass these settings through the ``options``
81+
argument, e.g. ``BasePlot(options=BasePlotOptions(title="My plot", type="image"))``
82+
(a dictionary is also accepted).
8283

8384
Renamed update_curve and update_image methods
8485
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -147,7 +148,7 @@ algorithm provided by the `scikit-image` library.
147148
As a consequence, the applications that previously depended on `matplotlib` only for
148149
contour detection can now drop this dependency.
149150

150-
See demo script `tests/items/test_contour.py`.
151+
See demo script `tests/items/test_contours.py`.
151152

152153
MaskedXYImages
153154
~~~~~~~~~~~~~~
@@ -176,7 +177,7 @@ New methods for creating ready-to-use plots have been added to the class:
176177
The method :py:meth:`.PlotBuilder.contours` has been added, in order to create
177178
contour curves. It returns a list of :py:class:`plotpy.items.ContourItem` objects.
178179

179-
See demo script `tests/items/test_contour.py`.
180+
See demo script `tests/items/test_contours.py`.
180181

181182
The new keyword parameter ``alpha_function`` has been added to the methods
182183
:py:meth:`.PlotBuilder.image`, :py:meth:`.PlotBuilder.xyimage`,

‎doc/release_notes/release_2.11.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Version 2.11 #
22

3+
## PlotPy Version 2.11.1 ##
4+
5+
🛠️ Bug fixes:
6+
7+
* **`hist_range_threshold` documentation** — Fixed the docstring of `plotpy.lutrange.hist_range_threshold`, which stated that `percent` was the share of the histogram mass to *retain*, whereas it is the share to *eliminate* (half on each side). The error message raised for an out-of-range `percent` now matches the accepted range `[0, 100]`
8+
9+
📚 Documentation:
10+
11+
* **Migrating from guiqwt** — Updated the migration guide to match the current API:
12+
* Fixed outdated targets (`BasePlotWidget`, `BasePlot`) and the contour demo script path
13+
* Updated the `BasePlot` constructor section: all configuration settings now go through `BasePlotOptions`
14+
* Added equivalents for `canvas2plotitem`/`plotitem2canvas` (`plotpy.coords`), `mimedata2url` (`guidata.qthelpers`), `guiqwt.transitional` (`qwt` package) and guidance for `eliminate_outliers` and `guiqwt.signals`
15+
* Completed the compatibility table with missing guiqwt modules and classes (`builder`, `panels`, `config`, `ImagePlot`, `ImageWidget`, `ImageDialog`, `ImageWindow`, ...)
16+
317
## PlotPy Version 2.11.0 ##
418

519
✨ New features:

‎plotpy/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
.. _GitHub: https://github.com/PierreRaybaut/plotpy
2121
"""
2222

23-
__version__ = "2.11.0"
23+
__version__ = "2.11.1"
2424
__VERSION__ = tuple([int(number) for number in __version__.split(".")])
2525

2626
# --- Important note: DATAPATH and LOCALEPATH are used by guidata.configtools

‎plotpy/locale/fr/LC_MESSAGES/plotpy.po‎

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,21 @@ msgstr "linéaire"
364364
msgid "date/time"
365365
msgstr "date/heure"
366366

367+
msgid "Autoscale strategy"
368+
msgstr "Stratégie d'autoscale"
369+
370+
msgid "Auto"
371+
msgstr "Automatique"
372+
373+
msgid "Fixed range"
374+
msgstr "Plage fixe"
375+
376+
msgid "Disabled"
377+
msgstr "Désactivée"
378+
379+
msgid "Strategy used by the AutoScale action for this axis: 'Auto' computes bounds from items, 'Fixed range' applies the Min/Max values defined above, 'Disabled' leaves the axis untouched."
380+
msgstr "Stratégie utilisée par l'action AutoScale pour cet axe : « Automatique » calcule les bornes à partir des éléments, « Plage fixe » applique les valeurs Min/Max définies ci-dessus, « Désactivée » laisse l'axe inchangé."
381+
367382
msgid "Lower axis limit"
368383
msgstr "Borne inférieure de l'axe"
369384

@@ -544,6 +559,9 @@ msgstr "Taille"
544559
msgid "Border"
545560
msgstr "Bordure"
546561

562+
msgid "Border width"
563+
msgstr "Largueur de bordure"
564+
547565
msgid "Background color"
548566
msgstr "Couleur du fond"
549567

@@ -1422,11 +1440,12 @@ msgid ""
14221440
"<b>Keyboard/mouse shortcuts:</b><br><br>\n"
14231441
" - <u>single left-click</u>: item (curve, image, ...) selection<br>\n"
14241442
" - <u>single right-click</u>: context-menu relative to selected item<br>\n"
1425-
" - <u>shift</u>: on-active-curve (or image) cursor<br>\n"
1426-
" - <u>shift + control</u>: on-active-curve cursor (maintained visible)<br>\n"
1443+
" - <u>shift</u>: on-active-curve (or image) cursor (+ <u>control</u> to maintain\n"
1444+
"cursor visible)<br>\n"
1445+
" - <u>shift + control</u>: on-active-curve cursor (+ <u>control</u> to maintain\n"
1446+
"cursor visible)<br>\n"
14271447
" - <u>alt</u>: free cursor<br>\n"
14281448
" - <u>left-click + mouse move</u>: move item (when available)<br>\n"
1429-
" - <u>control + left-click + mouse move</u>: move label on markers and range selections<br>\n"
14301449
" - <u>middle-click + mouse move</u>: pan<br>\n"
14311450
" - <u>right-click + mouse move</u>: zoom"
14321451
msgstr ""
@@ -1685,45 +1704,3 @@ msgstr "Rotation et rognage"
16851704

16861705
msgid "Show cropping rectangle"
16871706
msgstr "Afficher le rectangle de rognage"
1688-
1689-
#, fuzzy
1690-
msgid "Border width"
1691-
msgstr "Bordure"
1692-
1693-
msgid ""
1694-
"<b>Keyboard/mouse shortcuts:</b><br><br>\n"
1695-
" - <u>single left-click</u>: item (curve, image, ...) selection<br>\n"
1696-
" - <u>single right-click</u>: context-menu relative to selected item<br>\n"
1697-
" - <u>shift</u>: on-active-curve (or image) cursor (+ <u>control</u> to maintain\n"
1698-
"cursor visible)<br>\n"
1699-
" - <u>shift + control</u>: on-active-curve cursor (+ <u>control</u> to maintain\n"
1700-
"cursor visible)<br>\n"
1701-
" - <u>alt</u>: free cursor<br>\n"
1702-
" - <u>left-click + mouse move</u>: move item (when available)<br>\n"
1703-
" - <u>middle-click + mouse move</u>: pan<br>\n"
1704-
" - <u>right-click + mouse move</u>: zoom"
1705-
msgstr ""
1706-
"<b>Raccourcis clavier et souris :</b><br><br>\n"
1707-
" - <u>clique gauche</u> : sélection d'un objet (courbe, image, ...)<br>\n"
1708-
" - <u>clique droit</u> : menu contextuel relatif à l'objet sélectionné<br>\n"
1709-
" - <u>shift</u> : curseur sur la courbe (ou l'image) active (+ <u>control</u> pour maintenir le curseur visible)<br>\n"
1710-
" - <u>shift + control</u> : curseur sur la courbe (ou l'image) active (+ <u>control</u> pour maintenir le curseur visible)<br>\n"
1711-
" - <u>alt</u> : curseur libre<br>\n"
1712-
" - <u>clique gauche + déplacement souris</u> : déplacement de l'objet actif (si possible)<br>\n"
1713-
" - <u>clique du milieu + déplacement souris</u> : translation dans le plan ('pan')<br>\n"
1714-
" - <u>clique droit + déplacement souris</u> : agrandissement ('zoom')"
1715-
1716-
msgid "Autoscale strategy"
1717-
msgstr "Stratégie d'autoscale"
1718-
1719-
msgid "Auto"
1720-
msgstr "Automatique"
1721-
1722-
msgid "Fixed range"
1723-
msgstr "Plage fixe"
1724-
1725-
msgid "Disabled"
1726-
msgstr "Désactivée"
1727-
1728-
msgid "Strategy used by the AutoScale action for this axis: 'Auto' computes bounds from items, 'Fixed range' applies the Min/Max values defined above, 'Disabled' leaves the axis untouched."
1729-
msgstr "Stratégie utilisée par l'action AutoScale pour cet axe : « Automatique » calcule les bornes à partir des éléments, « Plage fixe » applique les valeurs Min/Max définies ci-dessus, « Désactivée » laisse l'axe inchangé."

‎plotpy/lutrange.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
def hist_range_threshold(
3030
hist: np.ndarray, bin_edges: np.ndarray, percent: float
3131
) -> tuple[float, float]:
32-
"""Return the range corresponding to the central `percent` of the histogram mass.
33-
This can be used to eliminate outliers symmetrically, e.g. for contrast adjustment.
32+
"""Return the range obtained by removing `percent` of the histogram mass.
33+
Outliers are eliminated symmetrically (`percent / 2` on each side),
34+
e.g. for contrast adjustment.
3435
3536
Notes:
3637
- If the histogram comes from an image with integer values (e.g. 0-255),
@@ -40,14 +41,14 @@ def hist_range_threshold(
4041
Args:
4142
hist: The histogram (length N)
4243
bin_edges: The bin edges (length N+1)
43-
percent: Percent of histogram mass to retain (between 0 and 100)
44+
percent: Percent of histogram mass to eliminate (between 0 and 100)
4445
4546
Returns:
4647
A tuple containing the minimum and maximum values of the range
47-
corresponding to the central `percent` of the histogram mass.
48+
remaining after removing `percent` of the histogram mass.
4849
"""
4950
if not (0 <= percent <= 100):
50-
raise ValueError("percent must be in (0, 100]")
51+
raise ValueError("percent must be in [0, 100]")
5152

5253
hist_len = len(hist)
5354
i_offset = 0

0 commit comments

Comments
 (0)