Skip to content

Miscelaneous, uninteresting whitespace & docstring fixes. #910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
49 changes: 13 additions & 36 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import matplotlib.units as munits
import numpy as np


GRIDLINE_INTERPOLATION_STEPS = 180


class Tick(artist.Artist):
"""
Abstract base class for the axis ticks, grid lines and labels
Expand Down Expand Up @@ -159,7 +161,6 @@ def apply_tickdir(self, tickdir):
"""
pass


def get_children(self):
children = [self.tick1line, self.tick2line, self.gridline, self.label1, self.label2]
return children
Expand Down Expand Up @@ -216,7 +217,6 @@ def _get_gridline(self):
'Get the default grid Line2d instance for this tick'
pass


def get_loc(self):
'Return the tick location (data coords) as a scalar'
return self._loc
Expand Down Expand Up @@ -308,7 +308,6 @@ def _apply_params(self, **kw):
setattr(self, '_'+k, v)



class XTick(Tick):
"""
Contains all the Artists needed to make an x tick - the tick line,
Expand Down Expand Up @@ -358,7 +357,6 @@ def _get_text1(self):


def _get_text2(self):

'Get the default Text 2 instance'
# x in data coords, y in axes coords
#t = mtext.Text(
Expand Down Expand Up @@ -479,7 +477,6 @@ def apply_tickdir(self, tickdir):
self._tickmarkers = (mlines.TICKLEFT, mlines.TICKRIGHT)
self._pad = self._base_pad + self._size


# how far from the y axis line the right of the ticklabel are
def _get_text1(self):
'Get the default Text instance'
Expand Down Expand Up @@ -557,7 +554,6 @@ def _get_gridline(self):
self._set_artist_props(l)
return l


def update_position(self, loc):
'Set the location of tick in data coords with scalar loc'
y = loc
Expand All @@ -584,7 +580,6 @@ def update_position(self, loc):

self._loc = loc


def get_view_interval(self):
'return the Interval instance for this axis view limits'
return self.axes.viewLim.intervaly
Expand All @@ -595,9 +590,7 @@ class Ticker:
formatter = None



class Axis(artist.Artist):

"""
Public attributes

Expand Down Expand Up @@ -632,12 +625,6 @@ def __init__(self, axes, pickradius=15):
self.minor = Ticker()
self.callbacks = cbook.CallbackRegistry()

#class dummy:
# locator = None
# formatter = None
#self.major = dummy()
#self.minor = dummy()

self._autolabelpos = True
self._smart_bounds = False

Expand All @@ -655,7 +642,6 @@ def __init__(self, axes, pickradius=15):
self.cla()
self.set_scale('linear')


def set_label_coords(self, x, y, transform=None):
"""
Set the coordinates of the label. By default, the x
Expand Down Expand Up @@ -706,7 +692,7 @@ def get_children(self):
return children

def cla(self):
'clear the current axis'
"""Clear the current axis"""
self.set_major_locator(mticker.AutoLocator())
self.set_major_formatter(mticker.ScalarFormatter())
self.set_minor_locator(mticker.NullLocator())
Expand Down Expand Up @@ -773,10 +759,10 @@ def set_tick_params(self, which='major', reset=False, **kw):
self.reset_ticks()
else:
if which == 'major' or which == 'both':
for tick in self.majorTicks:
for tick in self.majorTicks:
tick._apply_params(**self._major_tick_kw)
if which == 'minor' or which == 'both':
for tick in self.minorTicks:
for tick in self.minorTicks:
tick._apply_params(**self._minor_tick_kw)

@staticmethod
Expand Down Expand Up @@ -1018,7 +1004,6 @@ def get_tightbbox(self, renderer):
self._update_offset_text_position(ticklabelBoxes, ticklabelBoxes2)
self.offsetText.set_text( self.major.formatter.get_offset() )


bb = []

for a in [self.label, self.offsetText]:
Expand All @@ -1036,10 +1021,9 @@ def get_tightbbox(self, renderer):
else:
return None


@allow_rasterization
def draw(self, renderer, *args, **kwargs):
'Draw the axis lines, grid lines, tick lines and labels'
"""Draw the axis lines, grid lines, tick lines and labels"""

if not self.get_visible(): return
renderer.open_group(__name__)
Expand All @@ -1063,10 +1047,10 @@ def draw(self, renderer, *args, **kwargs):
self.offsetText.set_text( self.major.formatter.get_offset() )
self.offsetText.draw(renderer)

if 0: # draw the bounding boxes around the text for debug
for tick in majorTicks:
if False: # draw the bounding boxes around the text for debug
for tick in ticks_to_draw:
label = tick.label1
mpatches.bbox_artist(label, renderer)
mpatches.bbox_artist(label, renderer, fill=False)
mpatches.bbox_artist(self.label, renderer)

renderer.close_group(__name__)
Expand Down Expand Up @@ -1213,7 +1197,6 @@ def get_major_ticks(self, numticks=None):

return ticks


def get_minor_ticks(self, numticks=None):
'get the minor tick instances; grow as necessary'
if numticks is None:
Expand All @@ -1237,7 +1220,6 @@ def get_minor_ticks(self, numticks=None):

return ticks


def grid(self, b=None, which='major', **kwargs):
"""
Set the axis grid on or off; b is a boolean. Use *which* =
Expand Down Expand Up @@ -1343,7 +1325,7 @@ def convert_units(self, x):

def set_units(self, u):
"""
set the units for axis
Set the units for axis

ACCEPTS: a units tag
"""
Expand All @@ -1366,7 +1348,8 @@ def get_units(self):
return self.units

def set_label_text(self, label, fontdict = None, **kwargs):
""" Sets the text value of the axis label
"""
Sets the text value of the axis label

ACCEPTS: A string value for the label
"""
Expand All @@ -1386,7 +1369,6 @@ def set_major_formatter(self, formatter):
self.major.formatter = formatter
formatter.set_axis(self)


def set_minor_formatter(self, formatter):
"""
Set the formatter of the minor ticker
Expand All @@ -1408,7 +1390,6 @@ def set_major_locator(self, locator):
self.major.locator = locator
locator.set_axis(self)


def set_minor_locator(self, locator):
"""
Set the locator of the minor ticker
Expand All @@ -1427,7 +1408,6 @@ def set_pickradius(self, pickradius):
"""
self.pickradius = pickradius


def set_ticklabels(self, ticklabels, *args, **kwargs):
"""
Set the text values of the tick labels. Return a list of Text
Expand Down Expand Up @@ -1511,7 +1491,6 @@ def zoom(self, direction):
"Zoom in/out on axis; if *direction* is >0 zoom in, else zoom out"
self.major.locator.zoom(direction)


def axis_date(self, tz=None):
"""
Sets up x-axis ticks and labels that treat the x data as dates.
Expand All @@ -1526,7 +1505,7 @@ def axis_date(self, tz=None):
if isinstance(tz, (str, unicode)):
import pytz
tz = pytz.timezone(tz)
self.update_units(datetime.datetime(2009,1,1,0,0,0,0,tz))
self.update_units(datetime.datetime(2009, 1, 1, 0, 0, 0, 0, tz))


class XAxis(Axis):
Expand Down Expand Up @@ -1786,7 +1765,6 @@ def set_default_intervals(self):
self.axes.viewLim.intervalx = xmin, xmax



class YAxis(Axis):
__name__ = 'yaxis'
axis_name = 'y'
Expand Down Expand Up @@ -1818,7 +1796,6 @@ def _get_tick(self, major):
tick_kw = self._minor_tick_kw
return YTick(self.axes, 0, '', major=major, **tick_kw)


def _get_label(self):
# x in display coords (updated by _update_label_position)
# y in axes coords
Expand Down
22 changes: 6 additions & 16 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def mainloop(self):
pass



class RendererBase:
"""An abstract base class to handle drawing/rendering operations.

Expand Down Expand Up @@ -518,7 +517,6 @@ def _get_text_path_transform(self, x, y, s, prop, angle, ismath):

return path, transform


def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath):
"""
draw the text by converting them to paths using textpath module.
Expand All @@ -542,7 +540,6 @@ def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath):
gc.set_linewidth(0.0)
self.draw_path(gc, path, transform, rgbFace=color)


def get_text_width_height_descent(self, s, prop, ismath):
"""
get the width and height, and the offset from the bottom to the
Expand Down Expand Up @@ -1132,13 +1129,15 @@ def __init__(self, name, canvas,guiEvent=None):
self.canvas = canvas
self.guiEvent = guiEvent


class IdleEvent(Event):
"""
An event triggered by the GUI backend when it is idle -- useful
for passive animation
"""
pass


class DrawEvent(Event):
"""
An event triggered by a draw operation on the canvas
Expand All @@ -1153,6 +1152,7 @@ def __init__(self, name, canvas, renderer):
Event.__init__(self, name, canvas)
self.renderer = renderer


class ResizeEvent(Event):
"""
An event triggered by a canvas resize
Expand All @@ -1170,6 +1170,7 @@ def __init__(self, name, canvas):
Event.__init__(self, name, canvas)
self.width, self.height = canvas.get_width_height()


class CloseEvent(Event):
"""
An event triggered by a figure being closed
Expand All @@ -1179,6 +1180,7 @@ class CloseEvent(Event):
def __init__(self, name, canvas, guiEvent=None):
Event.__init__(self, name, canvas, guiEvent)


class LocationEvent(Event):
"""
An event that has a screen location
Expand Down Expand Up @@ -1222,8 +1224,6 @@ def __init__(self, name, canvas, x, y,guiEvent=None):
self.x = x
self.y = y



if x is None or y is None:
# cannot check if event was in axes if no x,y info
self.inaxes = None
Expand Down Expand Up @@ -1284,9 +1284,6 @@ def _update_enter_leave(self):
LocationEvent.lastevent = self





class MouseEvent(LocationEvent):
"""
A mouse event ('button_press_event', 'button_release_event', 'scroll_event',
Expand Down Expand Up @@ -1338,6 +1335,7 @@ def __str__(self):
return "MPL MouseEvent: xy=(%d,%d) xydata=(%s,%s) button=%d dblclick=%s inaxes=%s"%\
(self.x,self.y,str(self.xdata),str(self.ydata),self.button,self.dblclick,self.inaxes)


class PickEvent(Event):
"""
a pick event, fired when the user picks a location on the canvas
Expand Down Expand Up @@ -1408,7 +1406,6 @@ def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None):
self.key = key



class FigureCanvasBase(object):
"""
The canvas the figure renders into.
Expand Down Expand Up @@ -1437,7 +1434,6 @@ class FigureCanvasBase(object):
'close_event'
]


def __init__(self, figure):
figure.set_canvas(self)
self.figure = figure
Expand Down Expand Up @@ -1633,7 +1629,6 @@ def scroll_event(self, x, y, step, guiEvent=None):
step=step, guiEvent=guiEvent)
self.callbacks.process(s, mouseevent)


def button_press_event(self, x, y, button, dblclick=False, guiEvent=None):
"""
Backend derived classes should call this function on any mouse
Expand Down Expand Up @@ -1895,7 +1890,6 @@ def get_supported_filetypes_grouped(self):
groupings[name].sort()
return groupings


def _get_print_method(self, format):
method_name = 'print_%s' % format

Expand All @@ -1921,7 +1915,6 @@ def _print_method(*args, **kwargs):

return getattr(self, method_name)


def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
orientation='portrait', format=None, **kwargs):
"""
Expand Down Expand Up @@ -2063,9 +2056,6 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
#self.figure.canvas.draw() ## seems superfluous
return result




def get_default_filetype(self):
raise NotImplementedError

Expand Down
Loading