3131from qtpy import QtWidgets as QW
3232from qtpy .QtPrintSupport import QPrinter
3333
34+ from plotpy import constants as cst
3435from plotpy import io
3536from plotpy .config import CONF , _
3637from plotpy .constants import PARAMETERS_TITLE_ICON , PlotType
@@ -149,14 +150,7 @@ class BasePlot(qwt.QwtPlot):
149150 options: plot options
150151 """
151152
152- Y_LEFT , Y_RIGHT , X_BOTTOM , X_TOP = (
153- qwt .QwtPlot .yLeft ,
154- qwt .QwtPlot .yRight ,
155- qwt .QwtPlot .xBottom ,
156- qwt .QwtPlot .xTop ,
157- )
158- # # To be replaced by (in the near future):
159- # Y_LEFT, Y_RIGHT, X_BOTTOM, X_TOP = range(4)
153+ Y_LEFT , Y_RIGHT , X_BOTTOM , X_TOP = cst .Y_LEFT , cst .Y_RIGHT , cst .X_BOTTOM , cst .X_TOP
160154 AXIS_IDS = (Y_LEFT , Y_RIGHT , X_BOTTOM , X_TOP )
161155 AXIS_NAMES = {"left" : Y_LEFT , "right" : Y_RIGHT , "bottom" : X_BOTTOM , "top" : X_TOP }
162156 AXIS_TYPES = {"lin" : qwt .QwtLinearScaleEngine , "log" : qwt .QwtLogScaleEngine }
@@ -331,7 +325,7 @@ def __init__(
331325 options .yreverse = False
332326 self .__autoYReverse = True
333327
334- self .colormap_axis = self .Y_RIGHT
328+ self .colormap_axis = cst .Y_RIGHT
335329
336330 self .__autoColorBarEnabled = False
337331 if options .force_colorbar_enabled or self .options .type == PlotType .IMAGE :
@@ -1916,7 +1910,7 @@ def edit_axis_parameters(self, axis_id: int) -> None:
19161910 axis_id (int): the axis ID
19171911 """
19181912 if axis_id != self .colormap_axis :
1919- if axis_id in (self .Y_LEFT , self .Y_RIGHT ):
1913+ if axis_id in (cst .Y_LEFT , cst .Y_RIGHT ):
19201914 title = _ ("Y Axis" )
19211915 else :
19221916 title = _ ("X Axis" )
@@ -2048,11 +2042,11 @@ def get_axis_direction(self, axis_id: int | str) -> bool:
20482042 Return axis direction of increasing values
20492043
20502044 Args:
2051- axis_id (int | str) : axis id (BasePlot .Y_LEFT, BasePlot .X_BOTTOM, ...)
2045+ axis_id: axis id (constants .Y_LEFT, constants .X_BOTTOM, ...)
20522046 or string: 'bottom', 'left', 'top' or 'right'
20532047
20542048 Returns:
2055- bool: False (default)
2049+ False (default)
20562050 """
20572051 axis_id = self .get_axis_id (axis_id )
20582052 return self .axes_reverse [axis_id ]
@@ -2062,8 +2056,8 @@ def set_axis_direction(self, axis_id: int | str, reverse: bool = False) -> None:
20622056 Set axis direction of increasing values
20632057
20642058 Args:
2065- axis_id (int | str) : axis id (BasePlot .Y_LEFT, BasePlot .X_BOTTOM, ...)
2066- or string: 'bottom', 'left', 'top' or 'right'
2059+ axis_id: axis id (constants .Y_LEFT, constants .X_BOTTOM, ...)
2060+ or string: 'bottom', 'left', 'top' or 'right'
20672061 reverse (bool): False (default)
20682062
20692063 If reverse is False:
@@ -2215,10 +2209,10 @@ def get_current_aspect_ratio(self) -> float | None:
22152209 (this happens when the plot has been shrunk to a size so that the
22162210 width is zero)
22172211 """
2218- dx = self .axisScaleDiv (self .X_BOTTOM ).range ()
2219- dy = self .axisScaleDiv (self .Y_LEFT ).range ()
2220- h = self .canvasMap (self .Y_LEFT ).pDist ()
2221- w = self .canvasMap (self .X_BOTTOM ).pDist ()
2212+ dx = self .axisScaleDiv (cst .X_BOTTOM ).range ()
2213+ dy = self .axisScaleDiv (cst .Y_LEFT ).range ()
2214+ h = self .canvasMap (cst .Y_LEFT ).pDist ()
2215+ w = self .canvasMap (cst .X_BOTTOM ).pDist ()
22222216 try :
22232217 return fabs ((h * dx ) / (w * dy ))
22242218 except ZeroDivisionError :
@@ -2264,8 +2258,8 @@ def apply_aspect_ratio(self, full_scale: bool = False) -> None:
22642258 abs (current_aspect - self .__aspect_ratio ) < self .EPSILON_ASPECT_RATIO
22652259 ):
22662260 return
2267- ymap = self .canvasMap (self .Y_LEFT )
2268- xmap = self .canvasMap (self .X_BOTTOM )
2261+ ymap = self .canvasMap (cst .Y_LEFT )
2262+ xmap = self .canvasMap (cst .X_BOTTOM )
22692263 h = ymap .pDist ()
22702264 w = xmap .pDist ()
22712265 dx1 , dy1 = xmap .sDist (), fabs (ymap .sDist ())
0 commit comments