@@ -224,7 +224,7 @@ def __call__(self, x, pos=None):
224224 (e.g. locs, offset, order of magnitude) must already be configured,
225225 typically by a prior call to ``format_ticks`` or ``set_locs``.
226226
227- *pos* defines the index into ``self.locs `` so that the format can
227+ *pos* defines the index into ``self._locs `` so that the format can
228228 depend on the location. ``pos=None`` indicates an unspecified
229229 location.
230230
@@ -293,7 +293,7 @@ def set_locs(self, locs):
293293 This method is called before computing the tick labels because some
294294 formatters need to know all tick locations to do so.
295295 """
296- self .locs = locs
296+ self ._locs = locs
297297
298298 @staticmethod
299299 def fix_minus (s ):
@@ -514,7 +514,7 @@ def __init__(self, useOffset=None, useMathText=None, useLocale=None, *,
514514 self .set_useOffset (useOffset )
515515 self .set_usetex (usetex )
516516 self .set_useMathText (useMathText )
517- self .orderOfMagnitude = 0
517+ self ._orderOfMagnitude = 0
518518 self .format = ''
519519 self ._scientific = True
520520 self ._powerlimits = mpl .rcParams ['axes.formatter.limits' ]
@@ -664,10 +664,10 @@ def __call__(self, x, pos=None):
664664 """
665665 Return the format for tick value *x* at position *pos*.
666666 """
667- if len (self .locs ) == 0 :
667+ if len (self ._locs ) == 0 :
668668 return ''
669669 else :
670- xp = (x - self .offset ) / (10. ** self .orderOfMagnitude )
670+ xp = (x - self .offset ) / (10. ** self ._orderOfMagnitude )
671671 if abs (xp ) < 1e-8 :
672672 xp = 0
673673 return self ._format_maybe_minus_and_locale (self .format , xp )
@@ -764,20 +764,20 @@ def get_offset(self):
764764 """
765765 Return scientific notation, plus offset.
766766 """
767- if len (self .locs ) == 0 :
767+ if len (self ._locs ) == 0 :
768768 return ''
769- if self .orderOfMagnitude or self .offset :
769+ if self ._orderOfMagnitude or self .offset :
770770 offsetStr = ''
771771 sciNotStr = ''
772772 if self .offset :
773773 offsetStr = self .format_data (self .offset )
774774 if self .offset > 0 :
775775 offsetStr = '+' + offsetStr
776- if self .orderOfMagnitude :
776+ if self ._orderOfMagnitude :
777777 if self ._usetex or self ._useMathText :
778- sciNotStr = self .format_data (10 ** self .orderOfMagnitude )
778+ sciNotStr = self .format_data (10 ** self ._orderOfMagnitude )
779779 else :
780- sciNotStr = '1e%d' % self .orderOfMagnitude
780+ sciNotStr = '1e%d' % self ._orderOfMagnitude
781781 if self ._useMathText or self ._usetex :
782782 if sciNotStr != '' :
783783 sciNotStr = r'\times\mathdefault{%s}' % sciNotStr
@@ -789,15 +789,15 @@ def get_offset(self):
789789
790790 def set_locs (self , locs ):
791791 # docstring inherited
792- self .locs = locs
793- if len (self .locs ) > 0 :
792+ self ._locs = locs
793+ if len (self ._locs ) > 0 :
794794 if self ._useOffset :
795795 self ._compute_offset ()
796796 self ._set_order_of_magnitude ()
797797 self ._set_format ()
798798
799799 def _compute_offset (self ):
800- locs = self .locs
800+ locs = self ._locs
801801 # Restrict to visible ticks.
802802 vmin , vmax = sorted (self .axis .get_view_interval ())
803803 locs = np .asarray (locs )
@@ -840,19 +840,19 @@ def _set_order_of_magnitude(self):
840840 # if using a numerical offset, find the exponent after applying the
841841 # offset. When lower power limit = upper <> 0, use provided exponent.
842842 if not self ._scientific :
843- self .orderOfMagnitude = 0
843+ self ._orderOfMagnitude = 0
844844 return
845845 if self ._powerlimits [0 ] == self ._powerlimits [1 ] != 0 :
846846 # fixed scaling when lower power limit = upper <> 0.
847- self .orderOfMagnitude = self ._powerlimits [0 ]
847+ self ._orderOfMagnitude = self ._powerlimits [0 ]
848848 return
849849 # restrict to visible ticks
850850 vmin , vmax = sorted (self .axis .get_view_interval ())
851- locs = np .asarray (self .locs )
851+ locs = np .asarray (self ._locs )
852852 locs = locs [(vmin <= locs ) & (locs <= vmax )]
853853 locs = np .abs (locs )
854854 if not len (locs ):
855- self .orderOfMagnitude = 0
855+ self ._orderOfMagnitude = 0
856856 return
857857 if self .offset :
858858 oom = math .floor (math .log10 (vmax - vmin ))
@@ -863,28 +863,28 @@ def _set_order_of_magnitude(self):
863863 else :
864864 oom = math .floor (math .log10 (val ))
865865 if oom <= self ._powerlimits [0 ]:
866- self .orderOfMagnitude = oom
866+ self ._orderOfMagnitude = oom
867867 elif oom >= self ._powerlimits [1 ]:
868- self .orderOfMagnitude = oom
868+ self ._orderOfMagnitude = oom
869869 else :
870- self .orderOfMagnitude = 0
870+ self ._orderOfMagnitude = 0
871871
872872 def _set_format (self ):
873873 # set the format string to format all the ticklabels
874- if len (self .locs ) < 2 :
874+ if len (self ._locs ) < 2 :
875875 # Temporarily augment the locations with the axis end points.
876- _locs = [* self .locs , * self .axis .get_view_interval ()]
876+ _locs = [* self ._locs , * self .axis .get_view_interval ()]
877877 else :
878- _locs = self .locs
879- locs = (np .asarray (_locs ) - self .offset ) / 10. ** self .orderOfMagnitude
878+ _locs = self ._locs
879+ locs = (np .asarray (_locs ) - self .offset ) / 10. ** self ._orderOfMagnitude
880880 loc_range = np .ptp (locs )
881881 # Curvilinear coordinates can yield two identical points.
882882 if loc_range == 0 :
883883 loc_range = np .max (np .abs (locs ))
884884 # Both points might be zero.
885885 if loc_range == 0 :
886886 loc_range = 1
887- if len (self .locs ) < 2 :
887+ if len (self ._locs ) < 2 :
888888 # We needed the end points only for the loc_range calculation.
889889 locs = locs [:- 2 ]
890890 loc_range_oom = int (math .floor (math .log10 (loc_range )))
@@ -1292,7 +1292,7 @@ def set_minor_number(self, minor_number):
12921292 self ._minor_number = minor_number
12931293
12941294 def set_locs (self , locs ):
1295- self .locs = np .array (locs )
1295+ self ._locs = np .array (locs )
12961296 self ._labelled .clear ()
12971297
12981298 if not self ._minor :
@@ -1318,7 +1318,7 @@ def set_locs(self, locs):
13181318 # the previous, and between the ticks and the next one. Ticks
13191319 # with smallest minimum are chosen. As tiebreak, the ticks
13201320 # with smallest sum is chosen.
1321- diff = np .diff (- np .log (1 / self .locs - 1 ))
1321+ diff = np .diff (- np .log (1 / self ._locs - 1 ))
13221322 space_pessimistic = np .minimum (
13231323 np .concatenate (((np .inf ,), diff )),
13241324 np .concatenate ((diff , (np .inf ,))),
@@ -1328,7 +1328,7 @@ def set_locs(self, locs):
13281328 + np .concatenate ((diff , (0 ,)))
13291329 )
13301330 good_minor = sorted (
1331- range (len (self .locs )),
1331+ range (len (self ._locs )),
13321332 key = lambda i : (space_pessimistic [i ], space_sum [i ]),
13331333 )[- self ._minor_number :]
13341334 self ._labelled .update (locs [i ] for i in good_minor )
@@ -1379,11 +1379,11 @@ def __call__(self, x, pos=None):
13791379 exponent = round (math .log10 (1 - x ))
13801380 s = self ._one_minus ("10^{%d}" % exponent )
13811381 elif x < 0.1 :
1382- s = self ._format_value (x , self .locs )
1382+ s = self ._format_value (x , self ._locs )
13831383 elif x > 0.9 :
1384- s = self ._one_minus (self ._format_value (1 - x , 1 - self .locs ))
1384+ s = self ._one_minus (self ._format_value (1 - x , 1 - self ._locs ))
13851385 else :
1386- s = self ._format_value (x , self .locs , sci_notation = False )
1386+ s = self ._format_value (x , self ._locs , sci_notation = False )
13871387 return r"$\mathdefault{%s}$" % s
13881388
13891389 def format_data_short (self , value ):
@@ -1489,18 +1489,18 @@ def __call__(self, x, pos=None):
14891489 If there is no currently offset in the data, it returns the best
14901490 engineering formatting that fits the given argument, independently.
14911491 """
1492- if len (self .locs ) == 0 or self .offset == 0 :
1492+ if len (self ._locs ) == 0 or self .offset == 0 :
14931493 return self .fix_minus (self .format_data (x ))
14941494 else :
1495- xp = (x - self .offset ) / (10. ** self .orderOfMagnitude )
1495+ xp = (x - self .offset ) / (10. ** self ._orderOfMagnitude )
14961496 if abs (xp ) < 1e-8 :
14971497 xp = 0
14981498 return self ._format_maybe_minus_and_locale (self .format , xp )
14991499
15001500 def set_locs (self , locs ):
15011501 # docstring inherited
1502- self .locs = locs
1503- if len (self .locs ) > 0 :
1502+ self ._locs = locs
1503+ if len (self ._locs ) > 0 :
15041504 vmin , vmax = sorted (self .axis .get_view_interval ())
15051505 if self ._useOffset :
15061506 self ._compute_offset ()
@@ -1514,25 +1514,25 @@ def set_locs(self, locs):
15141514 # value:
15151515 self .offset = round ((vmin + vmax )/ 2 , 3 )
15161516 # Use log1000 to use engineers' oom standards
1517- self .orderOfMagnitude = math .floor (math .log (vmax - vmin , 1000 ))* 3
1517+ self ._orderOfMagnitude = math .floor (math .log (vmax - vmin , 1000 ))* 3
15181518 self ._set_format ()
15191519
15201520 # Simplify a bit ScalarFormatter.get_offset: We always want to use
15211521 # self.format_data. Also we want to return a non-empty string only if there
1522- # is an offset, no matter what is self.orderOfMagnitude . If there _is_ an
1523- # offset, self.orderOfMagnitude is consulted. This behavior is verified
1522+ # is an offset, no matter what is self._orderOfMagnitude . If there _is_ an
1523+ # offset, self._orderOfMagnitude is consulted. This behavior is verified
15241524 # in `test_ticker.py`.
15251525 def get_offset (self ):
15261526 # docstring inherited
1527- if len (self .locs ) == 0 :
1527+ if len (self ._locs ) == 0 :
15281528 return ''
15291529 if self .offset :
15301530 offsetStr = ''
15311531 if self .offset :
15321532 offsetStr = self .format_data (self .offset )
15331533 if self .offset > 0 :
15341534 offsetStr = '+' + offsetStr
1535- sciNotStr = self .format_data (10 ** self .orderOfMagnitude )
1535+ sciNotStr = self .format_data (10 ** self ._orderOfMagnitude )
15361536 if self ._useMathText or self ._usetex :
15371537 if sciNotStr != '' :
15381538 sciNotStr = r'\times%s' % sciNotStr
@@ -1844,8 +1844,8 @@ class FixedLocator(Locator):
18441844 """
18451845
18461846 def __init__ (self , locs , nbins = None ):
1847- self .locs = np .asarray (locs )
1848- _api .check_shape ((None ,), locs = self .locs )
1847+ self ._locs = np .asarray (locs )
1848+ _api .check_shape ((None ,), locs = self ._locs )
18491849 self .nbins = max (nbins , 2 ) if nbins is not None else None
18501850
18511851 def set_params (self , nbins = None ):
@@ -1865,11 +1865,11 @@ def tick_values(self, vmin, vmax):
18651865 Because the values are fixed, *vmin* and *vmax* are not used.
18661866 """
18671867 if self .nbins is None :
1868- return self .locs
1869- step = max (int (np .ceil (len (self .locs ) / self .nbins )), 1 )
1870- ticks = self .locs [::step ]
1868+ return self ._locs
1869+ step = max (int (np .ceil (len (self ._locs ) / self .nbins )), 1 )
1870+ ticks = self ._locs [::step ]
18711871 for i in range (1 , step ):
1872- ticks1 = self .locs [i ::step ]
1872+ ticks1 = self ._locs [i ::step ]
18731873 if np .abs (ticks1 ).min () < np .abs (ticks ).min ():
18741874 ticks = ticks1
18751875 return self .raise_if_exceeds (ticks )
0 commit comments