本文整理汇总了Python中skbio.stats.distance.DissimilarityMatrix.plot方法的典型用法代码示例。如果您正苦于以下问题:Python DissimilarityMatrix.plot方法的具体用法?Python DissimilarityMatrix.plot怎么用?Python DissimilarityMatrix.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.stats.distance.DissimilarityMatrix
的用法示例。
在下文中一共展示了DissimilarityMatrix.plot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_plot_no_default
# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import plot [as 别名]
def test_plot_no_default(self):
ids = ['0', 'one', '2', 'three', '4.000']
data = ([0, 1, 2, 3, 4], [1, 0, 1, 2, 3], [2, 1, 0, 1, 2],
[3, 2, 1, 0, 1], [4, 3, 2, 1, 0])
dm = DissimilarityMatrix(data, ids)
fig = dm.plot(cmap='Reds', title='Testplot')
self.assertIsInstance(fig, mpl.figure.Figure)
axes = fig.get_axes()
self.assertEqual(len(axes), 2)
ax = axes[0]
self.assertEqual(ax.get_title(), 'Testplot')
xticks = []
for tick in ax.get_xticklabels():
xticks.append(tick.get_text())
self.assertEqual(xticks, ['0', 'one', '2', 'three', '4.000'])
yticks = []
for tick in ax.get_yticklabels():
yticks.append(tick.get_text())
self.assertEqual(yticks, ['0', 'one', '2', 'three', '4.000'])
示例2: DissimilarityMatrixTests
# 需要导入模块: from skbio.stats.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.stats.distance.DissimilarityMatrix import plot [as 别名]
#.........这里部分代码省略.........
ids = ('b', 'a')
exp = DissimilarityMatrix([[0, 0.01], [0.01, 0]], ids)
obs = self.dm_3x3.filter(ids)
self.assertEqual(obs, exp)
# 4x4
dm = DissimilarityMatrix([[0, 1, 55, 7], [1, 0, 16, 1],
[55, 16, 0, 23], [7, 1, 23, 0]])
ids = np.asarray(['3', '0', '1'])
exp = DissimilarityMatrix([[0, 7, 1], [7, 0, 1], [1, 1, 0]], ids)
obs = dm.filter(ids)
self.assertEqual(obs, exp)
def test_filter_duplicate_ids(self):
with self.assertRaises(DissimilarityMatrixError):
self.dm_3x3.filter(['c', 'a', 'c'])
def test_filter_missing_ids(self):
with self.assertRaises(MissingIDError):
self.dm_3x3.filter(['c', 'bro'])
def test_filter_missing_ids_strict_false(self):
# no exception should be raised
ids = ('c', 'a')
exp = DissimilarityMatrix([[0, 4.2], [4.2, 0]], ids)
obs = self.dm_3x3.filter(['c', 'a', 'not found'], strict=False)
self.assertEqual(obs, exp)
def test_filter_empty_ids(self):
with self.assertRaises(DissimilarityMatrixError):
self.dm_3x3.filter([])
def test_plot_default(self):
fig = self.dm_1x1.plot()
self.assertIsInstance(fig, mpl.figure.Figure)
axes = fig.get_axes()
self.assertEqual(len(axes), 2)
ax = axes[0]
self.assertEqual(ax.get_title(), '')
xticks = []
for tick in ax.get_xticklabels():
xticks.append(tick.get_text())
self.assertEqual(xticks, ['a'])
yticks = []
for tick in ax.get_yticklabels():
yticks.append(tick.get_text())
self.assertEqual(yticks, ['a'])
def test_plot_no_default(self):
ids = ['0', 'one', '2', 'three', '4.000']
data = ([0, 1, 2, 3, 4], [1, 0, 1, 2, 3], [2, 1, 0, 1, 2],
[3, 2, 1, 0, 1], [4, 3, 2, 1, 0])
dm = DissimilarityMatrix(data, ids)
fig = dm.plot(cmap='Reds', title='Testplot')
self.assertIsInstance(fig, mpl.figure.Figure)
axes = fig.get_axes()
self.assertEqual(len(axes), 2)
ax = axes[0]
self.assertEqual(ax.get_title(), 'Testplot')
xticks = []
for tick in ax.get_xticklabels():
xticks.append(tick.get_text())
self.assertEqual(xticks, ['0', 'one', '2', 'three', '4.000'])
yticks = []
for tick in ax.get_yticklabels():