ot.plot
绘制OT矩阵的函数
函数
- ot.plot.plot1D_mat(a, b, M, title='', plot_style='yx', a_label='', b_label='', color_source='b', color_target='r', coupling_cmap='gray_r')[源]
绘制矩阵 \(\mathbf{M}\) 及源和目标的1D分布。
创建一个子图,用于显示源分布 \(\mathbf{a}\) 和目标分布 \(\mathbf{b}\)。 在‘yx’模式(默认)下,源位于左侧,目标位于顶部;而在‘xy’模式下,源位于底部(翻转),目标位于左侧。 矩阵 \(\mathbf{M}\) 显示在中间。
- Parameters:
a (ndarray, shape (na,)) – 源分布
b (ndarray, shape (nb,)) – 目标分布
M (ndarray, shape (na, nb)) – 要绘制的矩阵
标题 (str, 可选) – 图表的标题
plot_style (str, 可选) – 图表的样式,‘yx’ 或 ‘xy’。‘yx’ 将源放在左侧,目标放在顶部,‘xy’ 将源放在底部(倒置)和目标放在左侧。
a_label (str, 可选) – 源分发的标签
b_label (str, 可选) – 目标分布的标签
color_source (str, 可选) – 源分布的颜色
color_target (str, 可选) – 目标分布的颜色
coupling_cmap (str, optional) – 结合矩阵的颜色图
- Returns:
ax1 (源图 ax)
ax2 (目标图 ax)
ax3 (耦合图 ax)
使用 ot.plot.plot1D_mat 的示例
使用 ot.plot.plot2D_samples_mat 的示例
使用 ot.plot.rescale_for_imshow_plot 的示例
- ot.plot.plot1D_mat(a, b, M, title='', plot_style='yx', a_label='', b_label='', color_source='b', color_target='r', coupling_cmap='gray_r')[源]
绘制矩阵 \(\mathbf{M}\) 及源和目标的1D分布。
创建一个子图,用于显示源分布 \(\mathbf{a}\) 和目标分布 \(\mathbf{b}\)。 在‘yx’模式(默认)下,源位于左侧,目标位于顶部;而在‘xy’模式下,源位于底部(翻转),目标位于左侧。 矩阵 \(\mathbf{M}\) 显示在中间。
- Parameters:
a (ndarray, shape (na,)) – 源分布
b (ndarray, shape (nb,)) – 目标分布
M (ndarray, shape (na, nb)) – 要绘制的矩阵
标题 (str, 可选) – 图表的标题
plot_style (str, 可选) – 图表的样式,‘yx’ 或 ‘xy’。‘yx’ 将源放在左侧,目标放在顶部,‘xy’ 将源放在底部(倒置)和目标放在左侧。
a_label (str, 可选) – 源分发的标签
b_label (str, 可选) – 目标分布的标签
color_source (str, 可选) – 源分布的颜色
color_target (str, 可选) – 目标分布的颜色
coupling_cmap (str, optional) – 结合矩阵的颜色图
- Returns:
ax1 (源图 ax)
ax2 (目标图 ax)
ax3 (耦合图 ax)
- ot.plot.plot2D_samples_mat(xs, xt, G, thr=1e-08, **kwargs)[源]
使用 alpha 值在 2D 中绘制矩阵 \(\mathbf{G}\) 的线条
在源和目标的二维样本之间绘制线条,颜色与样本之间矩阵 \(\mathbf{G}\) 的值成正比。