Wie zeichne ich ein Rechteck mit Farbe, die einen Wert wie dieses Bild in Python darstellt? Zeichnen eines Rechtecks, das einen Wert in Python darstellt?
Ich habe ein Rechteck gezeigt, aber immer noch versucht, Werte im Rechteck anzuzeigen!
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
fig = plt.figure()
ax = fig.add_subplot(111)
rect1 = matplotlib.patches.Rectangle((0,1), 5, 0.5, color='c')
ax.add_patch(rect1)
ax.grid()
plt.xlim([-5, 20])
plt.ylim([-5, 6])
plt.show()
someX, someY = 0.5, 0.5
plt.figure()
currentAxis = plt.gca()
currentAxis.add_patch(Rectangle((someX - .1, someY - .1), 0.2, 0.2, color = 'c', alpha=0.5))
plt.grid()
plt.show()
great! Vielen Dank! –