0
votes

I wanna plot a scatter to visualize my result using 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])

But I found that sometimes the scalars of the axis are stacked together, like this in the source bias: enter image description here

Is there any method that can solve the problem without changing the font size, like setting fewer scale marks at the axis. I still want the same scaling of x- and y-axis (1:1 square) by the way.

1

1 Answers

1
votes

You could rotate the xticks.

plt.xticks(rotation=45, horizontalalignment='right')