Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added functionality to manually set offset/scaling string
  • Loading branch information
VincentVandalon committed Mar 1, 2016
commit 09f800ccf74c7299318e9f820fcfff452abf64d3
24 changes: 23 additions & 1 deletion lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ def __init__(self, useOffset=None, useMathText=None, useLocale=None):
self.orderOfMagnitude = 0
self.format = ''
self._scientific = True
self._offsetString = ''
self._powerlimits = rcParams['axes.formatter.limits']
if useLocale is None:
useLocale = rcParams['axes.formatter.use_locale']
Expand Down Expand Up @@ -592,11 +593,29 @@ def format_data(self, value):
return self.fix_minus(s)


def set_offset_string(self,s):
"""
Set the string which typically contains the offset
or the scaling factor which is to be displayed on the axis.
Set this to and empty string "" allows the string set by offset or scaling
algorithm.

Parameters
----------
s: String describing the offset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a space before the :


Returns
-------
None
"""
self._offsetString=s

def get_offset(self):
"""
Returns a string with the offset(or scientific notation)/scaling
factor which is properly formatted. This is used as additional text
next to the ticks.
next to the ticks, either determined by offset/scaling or set by the
user

Parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not include unneeded sections.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if you mean (1) leave it as it was or (2) no documentation needed for this method as a user will probably not use this method. Which one do you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the docstring is good, just do not include the Parameters section (as there ane no parameters).

----------
Expand All @@ -606,6 +625,9 @@ def get_offset(self):
-------
:string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no : here

"""
#String has been set manually, so just return that
if self._offsetString != '' :
return self._offsetString

if len(self.locs) == 0:
return ''
Expand Down