Wie mache ich eine matplotlib scatter-plot square?

In gnuplot kann ich tun dies, um ein Quadrat zeichnen:

set size square

Was ist das äquivalent in matplotlib? Ich habe dies ausprobiert:

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.rcParams['backend'] = 'TkAgg'
x = [0, 0.2, 0.4, 0.6, 0.8]
y = [0, 0.5, 1, 1.5, 2.0]
colors = ['k']*len(x)
plt.scatter(x, y, c=colors, alpha=0.5)
plt.axes().set_aspect('equal', adjustable='datalim')
plt.xlim((0,2))
plt.ylim((0,2))
plt.grid(b=True, which='major', color='k', linestyle='--')
plt.savefig('{}.png'.format(rsID), dpi=600)
plt.close()
plt.clf()

Bekomme ich ein quadratisches raster, sondern die Handlung selbst ist nicht quadratisch. Wie kann ich die x-Reihe geht es von 0 zu 2 und das Grundstück Platz?
Wie mache ich eine matplotlib scatter-plot square?

Schreibe einen Kommentar