本文整理汇总了Python中matplotlib.ticker.NullLocator方法的典型用法代码示例。如果您正苦于以下问题:Python ticker.NullLocator方法的具体用法?Python ticker.NullLocator怎么用?Python ticker.NullLocator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.ticker
的用法示例。
在下文中一共展示了ticker.NullLocator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _remove_labels_from_axis
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def _remove_labels_from_axis(axis):
for t in axis.get_majorticklabels():
t.set_visible(False)
try:
# set_visible will not be effective if
# minor axis has NullLocator and NullFormattor (default)
import matplotlib.ticker as ticker
if isinstance(axis.get_minor_locator(), ticker.NullLocator):
axis.set_minor_locator(ticker.AutoLocator())
if isinstance(axis.get_minor_formatter(), ticker.NullFormatter):
axis.set_minor_formatter(ticker.FormatStrFormatter(''))
for t in axis.get_minorticklabels():
t.set_visible(False)
except Exception: # pragma no cover
raise
axis.get_label().set_visible(False)
示例2: cla
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def cla(self):
Axes.cla(self)
self.set_longitude_grid(30)
self.set_latitude_grid(15)
self.set_longitude_grid_ends(75)
self.xaxis.set_minor_locator(NullLocator())
self.yaxis.set_minor_locator(NullLocator())
self.xaxis.set_ticks_position('none')
self.yaxis.set_ticks_position('none')
self.yaxis.set_tick_params(label1On=True)
# Why do we need to turn on yaxis tick labels, but
# xaxis tick labels are already on?
self.grid(rcParams['axes.grid'])
Axes.set_xlim(self, -np.pi, np.pi)
Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
示例3: show_output
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def show_output(output, img):
fig, ax = plt.subplots(1)
ax.imshow(img)
for obj in output:
box = obj['box']
x1, y1, x2, y2 = box[0], box[1], box[2], box[3]
box_w = x2 - x1
box_h = y2 - y1
bbox = patches.Rectangle((x1, y1), box_w, box_h,
linewidth=2, edgecolor='red', facecolor="none")
ax.add_patch(bbox)
plt.text(
x1,
y1,
s=obj['name'],
color="white",
verticalalignment="top",
bbox={"color": 'red', "pad": 0},
)
plt.axis("off")
plt.gca().xaxis.set_major_locator(NullLocator())
plt.gca().yaxis.set_major_locator(NullLocator())
plt.show()
示例4: plot_activation
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def plot_activation(matrix, step, save_to=None):
save_to = os.path.join(".", "activations") if save_to is None else save_to
os.makedirs(save_to, exist_ok=True)
if len(matrix.shape) != 2:
raise ValueError('Input "matrix" should have 2 rank, but it is',str(len(matrix.shape)))
num_label = matrix.shape[1] - 1
matrix = matrix[matrix[:, num_label].argsort()]
fig, axes = plt.subplots(ncols=1, nrows=num_label, figsize=(15,12))
fig.suptitle("The probability of entity presence (step %s)"%str(step), fontsize=20)
fig.tight_layout()
for i, ax in enumerate(axes.flatten()):
idx = num_label - (i + 1)
ax.spines['top'].set_color('none')
ax.spines['bottom'].set_color('none')
ax.set_ylim(0, 1.05)
ax.set_ylabel("Capsule " + str(idx))
ax.yaxis.set_major_locator(ticker.NullLocator())
if idx > 0:
ax.xaxis.set_major_locator(ticker.NullLocator())
else:
ax.xaxis.set_major_locator(ticker.IndexLocator(base=500,offset=0))
ax.set_xlabel("Sample index ")
ax.plot(matrix[:,idx])
ax_prime = ax.twinx()
ax_prime.spines['top'].set_color('none')
ax_prime.spines['bottom'].set_color('none')
plt.subplots_adjust(hspace=0.2, left=0.05, right=0.95, bottom=0.05, top=.95)
plt.savefig(os.path.join(save_to, "activation_%s.png" % str(step)))
plt.close()
示例5: cla
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def cla(self):
'clear the current axis'
self.set_major_locator(mticker.AutoLocator())
self.set_major_formatter(mticker.ScalarFormatter())
self.set_minor_locator(mticker.NullLocator())
self.set_minor_formatter(mticker.NullFormatter())
self.set_label_text('')
self._set_artist_props(self.label)
# Keep track of setting to the default value, this allows use to know
# if any of the following values is explicitly set by the user, so as
# to not overwrite their settings with any of our 'auto' settings.
self.isDefault_majloc = True
self.isDefault_minloc = True
self.isDefault_majfmt = True
self.isDefault_minfmt = True
self.isDefault_label = True
# Clear the callback registry for this axis, or it may "leak"
self.callbacks = cbook.CallbackRegistry()
# whether the grids are on
self._gridOnMajor = rcParams['axes.grid']
self._gridOnMinor = False
self.label.set_text('')
self._set_artist_props(self.label)
self.reset_ticks()
self.converter = None
self.units = None
self.set_units(None)
示例6: minorticks_off
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def minorticks_off(self):
"""
Turns off the minor ticks on the colorbar.
"""
ax = self.ax
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis
long_axis.set_minor_locator(ticker.NullLocator())
示例7: minorticks_off
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def minorticks_off(self):
"""Remove minor ticks from the axes."""
self.xaxis.set_minor_locator(mticker.NullLocator())
self.yaxis.set_minor_locator(mticker.NullLocator())
# Interactive manipulation
示例8: cla
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def cla(self):
'clear the current axis'
self.set_major_locator(mticker.AutoLocator())
self.set_major_formatter(mticker.ScalarFormatter())
self.set_minor_locator(mticker.NullLocator())
self.set_minor_formatter(mticker.NullFormatter())
self.set_label_text('')
self._set_artist_props(self.label)
# Keep track of setting to the default value, this allows use to know
# if any of the following values is explicitly set by the user, so as
# to not overwrite their settings with any of our 'auto' settings.
self.isDefault_majloc = True
self.isDefault_minloc = True
self.isDefault_majfmt = True
self.isDefault_minfmt = True
self.isDefault_label = True
# Clear the callback registry for this axis, or it may "leak"
self.callbacks = cbook.CallbackRegistry()
# whether the grids are on
self._gridOnMajor = rcParams['axes.grid'] and (rcParams['axes.grid.which'] in ('both','major'))
self._gridOnMinor = rcParams['axes.grid'] and (rcParams['axes.grid.which'] in ('both','minor'))
self.label.set_text('')
self._set_artist_props(self.label)
self.reset_ticks()
self.converter = None
self.units = None
self.set_units(None)
示例9: minorticks_off
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def minorticks_off(self):
"""Remove minor ticks from the axes."""
self.xaxis.set_minor_locator(mticker.NullLocator())
self.yaxis.set_minor_locator(mticker.NullLocator())
#### Interactive manipulation
示例10: minorticks_off
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def minorticks_off(self):
"""
Turns off the minor ticks on the colorbar.
"""
ax = self.ax
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis
if long_axis.get_scale() == 'log':
warnings.warn('minorticks_off() has no effect on a '
'logarithmic colorbar axis')
else:
long_axis.set_minor_locator(ticker.NullLocator())
示例11: setup
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def setup(ax):
ax.spines['right'].set_color('none')
ax.spines['left'].set_color('none')
ax.yaxis.set_major_locator(ticker.NullLocator())
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.tick_params(which='major', width=1.00, length=5)
ax.tick_params(which='minor', width=0.75, length=2.5, labelsize=10)
ax.set_xlim(0, 5)
ax.set_ylim(0, 1)
ax.patch.set_alpha(0.0)
示例12: setup
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import NullLocator [as 别名]
def setup(ax):
ax.spines['right'].set_color('none')
ax.spines['left'].set_color('none')
ax.yaxis.set_major_locator(ticker.NullLocator())
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.tick_params(which='major', width=1.00)
ax.tick_params(which='major', length=5)
ax.tick_params(which='minor', width=0.75)
ax.tick_params(which='minor', length=2.5)
ax.set_xlim(0, 5)
ax.set_ylim(0, 1)
ax.patch.set_alpha(0.0)