【发布时间】:2020-07-27 21:19:08
【问题描述】:
我想绘制一个散点图以使用 matplotlib 可视化我的结果:
plt.subplot(1, 2, 1)
plt.scatter(source_weights, target_weights)
plt.xlabel('Source Weights', fontsize=13, fontweight='bold')
plt.ylabel('Target Weights', fontsize=13, fontweight='bold')
plt.xticks(fontsize=12, fontweight='bold')
plt.yticks(fontsize=12, fontweight='bold')
plt.axis('equal')
plt.axis('square')
y_lim = np.max(np.abs(target_weights))
x_lim = np.max(np.abs(source_weights))
lim = max(x_lim, y_lim)
_ = plt.plot([-1.1 * lim, 1.1 * lim], [-1.1 * lim, 1.1 * lim])
# plot bias difference
plt.subplot(1, 2, 2)
plt.scatter(source_bias, target_bias)
plt.xlabel('Source Bias', fontsize=13, fontweight='bold')
plt.ylabel('Target Bias', fontsize=13, fontweight='bold')
plt.xticks(fontsize=12, fontweight='bold')
plt.yticks(fontsize=12, fontweight='bold')
plt.axis('equal')
plt.axis('square')
y_lim = np.max(np.abs(target_bias))
x_lim = np.max(np.abs(source_bias))
lim = max(x_lim, y_lim)
_ = plt.plot([-1.1 * lim, 1.1 * lim], [-1.1 * lim, 1.1 * lim])
有没有什么方法可以在不改变字体大小的情况下解决这个问题,比如在轴上设置更少的刻度。顺便说一下,我仍然想要 x 轴和 y 轴(1:1 正方形)的相同缩放比例。
【问题讨论】:
标签: python matplotlib data-visualization