本文整理汇总了Python中matplotlib.markers.MarkerStyle方法的典型用法代码示例。如果您正苦于以下问题:Python markers.MarkerStyle方法的具体用法?Python markers.MarkerStyle怎么用?Python markers.MarkerStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.markers
的用法示例。
在下文中一共展示了markers.MarkerStyle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_latent_distribution
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def plot_latent_distribution(encoder,
x_test,
y_test,
batch_size=128):
"""
Display a 2D plot of the digit classes in the latent space.
We are interested only in z, so we only need the encoder here.
:param encoder: the encoder network
:param x_test: test images
:param y_test: test labels
:param batch_size: size of the mini-batch
"""
z_mean, _, _ = encoder.predict(x_test, batch_size=batch_size)
plt.figure(figsize=(6, 6))
markers = ('o', 'x', '^', '<', '>', '*', 'h', 'H', 'D', 'd', 'P', 'X', '8', 's', 'p')
for i in np.unique(y_test):
plt.scatter(z_mean[y_test == i, 0], z_mean[y_test == i, 1],
marker=MarkerStyle(markers[i], fillstyle='none'),
edgecolors='black')
plt.xlabel("z[0]")
plt.ylabel("z[1]")
plt.show()
示例2: get_marker_style
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def get_marker_style(line):
"""Get the style dictionary for matplotlib marker objects"""
style = {}
style['alpha'] = line.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['facecolor'] = export_color(line.get_markerfacecolor())
style['edgecolor'] = export_color(line.get_markeredgecolor())
style['edgewidth'] = line.get_markeredgewidth()
style['marker'] = line.get_marker()
markerstyle = MarkerStyle(line.get_marker())
markersize = line.get_markersize()
markertransform = (markerstyle.get_transform()
+ Affine2D().scale(markersize, -markersize))
style['markerpath'] = SVG_path(markerstyle.get_path(),
markertransform)
style['markersize'] = markersize
style['zorder'] = line.get_zorder()
return style
示例3: test_scatter_marker
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def test_scatter_marker(self):
fig, (ax0, ax1, ax2) = plt.subplots(ncols=3)
ax0.scatter([3, 4, 2, 6], [2, 5, 2, 3],
c=[(1, 0, 0), 'y', 'b', 'lime'],
s=[60, 50, 40, 30],
edgecolors=['k', 'r', 'g', 'b'],
marker='s')
ax1.scatter([3, 4, 2, 6], [2, 5, 2, 3],
c=[(1, 0, 0), 'y', 'b', 'lime'],
s=[60, 50, 40, 30],
edgecolors=['k', 'r', 'g', 'b'],
marker=mmarkers.MarkerStyle('o', fillstyle='top'))
# unit area ellipse
rx, ry = 3, 1
area = rx * ry * np.pi
theta = np.linspace(0, 2 * np.pi, 21)
verts = np.column_stack([np.cos(theta) * rx / area,
np.sin(theta) * ry / area])
ax2.scatter([3, 4, 2, 6], [2, 5, 2, 3],
c=[(1, 0, 0), 'y', 'b', 'lime'],
s=[60, 50, 40, 30],
edgecolors=['k', 'r', 'g', 'b'],
marker=verts)
示例4: get_marker_style
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def get_marker_style(line):
"""Get the style dictionary for matplotlib marker objects"""
style = {}
style['alpha'] = line.get_alpha()
if style['alpha'] is None:
style['alpha'] = 1
style['facecolor'] = color_to_hex(line.get_markerfacecolor())
style['edgecolor'] = color_to_hex(line.get_markeredgecolor())
style['edgewidth'] = line.get_markeredgewidth()
style['marker'] = line.get_marker()
markerstyle = MarkerStyle(line.get_marker())
markersize = line.get_markersize()
markertransform = (markerstyle.get_transform()
+ Affine2D().scale(markersize, -markersize))
style['markerpath'] = SVG_path(markerstyle.get_path(),
markertransform)
style['markersize'] = markersize
style['zorder'] = line.get_zorder()
return style
示例5: test_scatter_marker
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def test_scatter_marker():
fig, (ax0, ax1, ax2) = plt.subplots(ncols=3)
ax0.scatter([3, 4, 2, 6], [2, 5, 2, 3],
c=[(1, 0, 0), 'y', 'b', 'lime'],
s=[60, 50, 40, 30],
edgecolors=['k', 'r', 'g', 'b'],
marker='s')
ax1.scatter([3, 4, 2, 6], [2, 5, 2, 3],
c=[(1, 0, 0), 'y', 'b', 'lime'],
s=[60, 50, 40, 30],
edgecolors=['k', 'r', 'g', 'b'],
marker=mmarkers.MarkerStyle('o', fillstyle='top'))
# unit area ellipse
rx, ry = 3, 1
area = rx * ry * np.pi
theta = np.linspace(0, 2 * np.pi, 21)
verts = np.column_stack([np.cos(theta) * rx / area,
np.sin(theta) * ry / area])
ax2.scatter([3, 4, 2, 6], [2, 5, 2, 3],
c=[(1, 0, 0), 'y', 'b', 'lime'],
s=[60, 50, 40, 30],
edgecolors=['k', 'r', 'g', 'b'],
verts=verts)
示例6: test_marker_styles
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def test_marker_styles():
fig = plt.figure()
ax = fig.add_subplot(111)
for y, marker in enumerate(sorted(matplotlib.markers.MarkerStyle.markers,
key=lambda x: str(type(x))+str(x))):
ax.plot((y % 2)*5 + np.arange(10)*10, np.ones(10)*10*y, linestyle='',
marker=marker, markersize=10+y/5, label=marker)
示例7: test_markers_valid
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def test_markers_valid():
marker_style = markers.MarkerStyle()
mrk_array = np.array([[-0.5, 0],
[0.5, 0]])
# Checking this doesn't fail.
marker_style.set_marker(mrk_array)
示例8: test_markers_invalid
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def test_markers_invalid():
marker_style = markers.MarkerStyle()
mrk_array = np.array([[-0.5, 0, 1, 2, 3]])
# Checking this does fail.
with pytest.raises(ValueError):
marker_style.set_marker(mrk_array)
示例9: test_marker_path
# 需要导入模块: from matplotlib import markers [as 别名]
# 或者: from matplotlib.markers import MarkerStyle [as 别名]
def test_marker_path():
marker_style = markers.MarkerStyle()
path = Path([[0, 0], [1, 0]], [Path.MOVETO, Path.LINETO])
# Checking this doesn't fail.
marker_style.set_marker(path)