MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / Axes

Class Axes

lib/mpl_toolkits/axisartist/axislines.py:366–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364
365
366class Axes(maxes.Axes):
367
368 def __init__(self, *args, grid_helper=None, **kwargs):
369 self._axisline_on = True
370 self._grid_helper = grid_helper if grid_helper else GridHelperRectlinear(self)
371 super().__init__(*args, **kwargs)
372 self.toggle_axisline(True)
373
374 def toggle_axisline(self, b=None):
375 if b is None:
376 b = not self._axisline_on
377 if b:
378 self._axisline_on = True
379 self.spines[:].set_visible(False)
380 self.xaxis.set_visible(False)
381 self.yaxis.set_visible(False)
382 else:
383 self._axisline_on = False
384 self.spines[:].set_visible(True)
385 self.xaxis.set_visible(True)
386 self.yaxis.set_visible(True)
387
388 @property
389 def axis(self):
390 return self._axislines
391
392 def clear(self):
393 # docstring inherited
394
395 # Init gridlines before clear() as clear() calls grid().
396 self.gridlines = gridlines = GridlinesCollection(
397 [],
398 colors=mpl.rcParams['grid.color'],
399 linestyles=mpl.rcParams['grid.linestyle'],
400 linewidths=mpl.rcParams['grid.linewidth'])
401 self._set_artist_props(gridlines)
402 gridlines.set_grid_helper(self.get_grid_helper())
403
404 super().clear()
405
406 # clip_path is set after Axes.clear(): that's when a patch is created.
407 gridlines.set_clip_path(self.axes.patch)
408
409 # Init axis artists.
410 self._axislines = mpl_axes.Axes.AxisDict(self)
411 new_fixed_axis = self.get_grid_helper().new_fixed_axis
412 self._axislines.update({
413 loc: new_fixed_axis(loc=loc, axes=self, axis_direction=loc)
414 for loc in ["bottom", "top", "left", "right"]})
415 for axisline in [self._axislines["top"], self._axislines["right"]]:
416 axisline.label.set_visible(False)
417 axisline.major_ticklabels.set_visible(False)
418 axisline.minor_ticklabels.set_visible(False)
419
420 def get_grid_helper(self):
421 return self._grid_helper
422
423 def grid(self, visible=None, which='major', axis="both", **kwargs):

Callers 1

test_AxesFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_AxesFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…