Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 09f800c

Browse filesBrowse files
Added functionality to manually set offset/scaling string
1 parent bfc7389 commit 09f800c
Copy full SHA for 09f800c

File tree

Expand file treeCollapse file tree

1 file changed

+23
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-1
lines changed

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+23-1Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ def __init__(self, useOffset=None, useMathText=None, useLocale=None):
436436
self.orderOfMagnitude = 0
437437
self.format = ''
438438
self._scientific = True
439+
self._offsetString = ''
439440
self._powerlimits = rcParams['axes.formatter.limits']
440441
if useLocale is None:
441442
useLocale = rcParams['axes.formatter.use_locale']
@@ -592,11 +593,29 @@ def format_data(self, value):
592593
return self.fix_minus(s)
593594

594595

596+
def set_offset_string(self,s):
597+
"""
598+
Set the string which typically contains the offset
599+
or the scaling factor which is to be displayed on the axis.
600+
Set this to and empty string "" allows the string set by offset or scaling
601+
algorithm.
602+
603+
Parameters
604+
----------
605+
s: String describing the offset
606+
607+
Returns
608+
-------
609+
None
610+
"""
611+
self._offsetString=s
612+
595613
def get_offset(self):
596614
"""
597615
Returns a string with the offset(or scientific notation)/scaling
598616
factor which is properly formatted. This is used as additional text
599-
next to the ticks.
617+
next to the ticks, either determined by offset/scaling or set by the
618+
user
600619
601620
Parameters
602621
----------
@@ -606,6 +625,9 @@ def get_offset(self):
606625
-------
607626
:string
608627
"""
628+
#String has been set manually, so just return that
629+
if self._offsetString != '' :
630+
return self._offsetString
609631

610632
if len(self.locs) == 0:
611633
return ''

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.