8 examples of 'matplotlib remove axes' in Python

Every line of 'matplotlib remove axes' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
14def removeAxis(ax, which_ax=['top', 'right']):
15
16 for loc, spine in ax.spines.iteritems():
17 if loc in which_ax:
18 spine.set_color('none') # don't draw spine
19
20 ax.xaxis.set_ticks_position('bottom')
21 ax.yaxis.set_ticks_position('left')
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

191def relabel_axes(axes, n_points='auto', xvalues=None, yvalues=None, xlabel=None, ylabel=None, format_str='{:.2g}'):
192
193 if n_points=='auto':
194 n_points = 5 if len(xvalues)%5==0 else \
195 4 if len(xvalues)%4==0 else \
196 3 if len(xvalues)%3==0 else \
197 5
198 if xvalues is not None:
199 relabel_axis(axes.xaxis, xvalues, n_points=n_points, format_str=format_str)
200 if xlabel is not None:
201 axes.set_xlabel(xlabel)
202 if yvalues is not None:
203 relabel_axis(axes.yaxis, yvalues, n_points=n_points, format_str=format_str)
204 if ylabel is not None:
205 axes.set_ylabel(ylabel)
48def clear_ax(ax):
49 ax.spines['left'].set_visible(False)
50 ax.spines['right'].set_visible(False)
51 ax.spines['top'].set_visible(False)
52 ax.set_yticks([])
641def _makeAxes(self, nAxes: int) -> Axes:
642 """Create a grid of axes.
643 We try to keep the grid as square as possible.
644 """
645 nrows = int(nAxes ** .5 + .5)
646 ncols = np.ceil(nAxes / nrows)
647 axes = self.plot.clearFig(nrows, ncols, nAxes)
648 return axes
48def restyle(ax):
49 ax.spines['top'].set_visible(False)
50 ax.spines['right'].set_visible(False)
51 ax.spines['left'].set_visible(False)
52 ax.get_yaxis().set_visible(False)
53 ax.tick_params(
54 axis='x', # changes apply to the x-axis
55 which='both', # both major and minor ticks are affected
56 bottom=False,) # ticks along the bottom edge are off
57 ax.set_ylim((0.0, 1.0))
58 ax.get_legend().remove()
112def close_axes(self, ax):
113 """
114 Finish commands for a particular axes.
115
116 Parameters
117 ----------
118 ax : matplotlib.Axes
119 The Axes which is finished being drawn.
120 """
121 pass
53def despine(ax, all=False):
54 if all is True:
55 for sp in ax.spines:
56 ax.spines[sp].set_visible(False)
57 ax.get_xaxis().set_visible(False)
58 ax.get_yaxis().set_visible(False)
59 else:
60 ax.spines['top'].set_visible(False)
61 ax.spines['right'].set_visible(False)
62 ax.get_xaxis().tick_bottom()
63 ax.get_yaxis().tick_left()
20def square_axis(axes=None):
21 """
22 Expands the x- and y-limits on the given axes so that they are equal
23 (defaults to the current axes).
24 """
25 if axes is None:
26 axes = gca()
27 tmpv = axes.axis()
28 xmax = max([tmpv[1], tmpv[3]])
29 xmin = min([tmpv[0], tmpv[2]])
30 axes.axis([xmin, xmax, xmin, xmax])

Related snippets