本文整理汇总了Python中matplotlib.axes.Axes.set_xticklabels方法的典型用法代码示例。如果您正苦于以下问题:Python Axes.set_xticklabels方法的具体用法?Python Axes.set_xticklabels怎么用?Python Axes.set_xticklabels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.axes.Axes
的用法示例。
在下文中一共展示了Axes.set_xticklabels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_image
# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import set_xticklabels [as 别名]
def display_image(self):
# plot and save the image
img = self.compute_image()
# clear previous figure
self.fig.clf()
# setup plot
ax = Axes(self.fig, [0, 0, 1, 1]) # remove outer border
ax.set_axis_off() # disable axis
ax.set_xlim((self.xmin, self.xmax))
ax.set_ylim((self.ymin, self.ymax))
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.imshow(img, cmap=pl.get_cmap(self.cmap), interpolation='nearest',
extent=[self.xmin, self.xmax, self.ymin, self.ymax],
origin='upper', aspect=1.0)
self.fig.add_axes(ax)
示例2: plot_hex_and_violin
# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import set_xticklabels [as 别名]
def plot_hex_and_violin(abscissa, ordinate, bin_edges, extent=None,
xlabel="", ylabel="", zlabel="", do_hex=True, do_violin=True,
cm=plt.cm.inferno, axis=None, v_padding=.015, **kwargs):
"""
takes two arrays of coordinates and creates a 2D hexbin plot and a violin plot (or
just one of them)
Parameters
----------
abscissa, ordinate : arrays
the coordinates of the data to plot
bin_edges : array
bin edges along the abscissa
extent : 4-tuple of floats (default: None)
extension of the abscissa, ordinate; given as is to plt.hexbin
xlabel, ylabel : strings (defaults: "")
labels for the two axes of either plot
zlabel : string (default: "")
label for the colorbar of the hexbin plot
do_hex, do_violin : bools (defaults: True)
whether or not to do the respective plots
cm : colour map (default: plt.cm.inferno)
colour map to be used for the hexbin plot
kwargs : args dictionary
more arguments to be passed to plt.hexbin
"""
if axis:
if do_hex and do_violin:
from matplotlib.axes import Axes
from matplotlib.transforms import Bbox
axis_bbox = axis.get_position()
axis.axis("off")
else:
plt.sca(axis)
# make a normal 2D hexplot from the given data
if do_hex:
# if we do both plot types,
if do_violin:
if axis:
ax_hex_pos = axis_bbox.get_points().copy() # [[x0, y0], [x1, y1]]
ax_hex_pos[0, 1] += np.diff(ax_hex_pos, axis=0)[0, 1]*(.5+v_padding)
ax_hex = Axes(plt.gcf(), Bbox.from_extents(ax_hex_pos))
plt.gcf().add_axes(ax_hex)
plt.sca(ax_hex)
ax_hex.set_xticklabels([])
else:
plt.subplot(211)
plt.hexbin(abscissa,
ordinate,
gridsize=40,
extent=extent,
cmap=cm,
**kwargs)
cb = plt.colorbar()
cb.set_label(zlabel)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
if extent:
plt.xlim(extent[:2])
plt.ylim(extent[2:])
# prepare and draw the data for the violin plot
if do_violin:
# if we do both plot types, open a subplot
if do_hex:
if axis:
ax_vio_pos = axis_bbox.get_points().copy() # [[x0, y0], [x1, y1]]
ax_vio_pos[1, 1] -= np.diff(ax_vio_pos, axis=0)[0, 1]*(.5+v_padding)
ax_vio = Axes(plt.gcf(), Bbox.from_extents(ax_vio_pos))
plt.gcf().add_axes(ax_vio)
plt.sca(ax_vio)
else:
plt.subplot(212)
# to plot the violins, sort the ordinate values into a dictionary
# the keys are the central values of the bins given by `bin_edges`
val_vs_dep = {}
bin_centres = (bin_edges[1:]+bin_edges[:-1])/2.
for dep, val in zip(abscissa, ordinate):
# get the bin number this event belongs into
# outliers are put into the first and last bin accordingly
ibin = np.clip(np.digitize(dep, bin_edges)-1,
0, len(bin_centres)-1)
# the central value of the bin is the key for the dictionary
if bin_centres[ibin] not in val_vs_dep:
val_vs_dep[bin_centres[ibin]] = [val]
else:
val_vs_dep[bin_centres[ibin]] += [val]
keys = [k[0] for k in sorted(val_vs_dep.items())]
vals = [k[1] for k in sorted(val_vs_dep.items())]
#.........这里部分代码省略.........