Reputation: 25094
I'm plotting a simple graph but would like to draw all values on top to visualize the values. So how would I go from this:
import matplotlib.pyplot as plt
img = []
for x in range(0, 8):
row = []
for y in range(0, 8):
row.append(x+y)
img.append(row)
plt.imshow(img)
to this:
Upvotes: 0
Views: 434
Reputation: 36
plt.text does the job:
import matplotlib.pyplot as plt
img = []
for x in range(0, 8):
row = []
for y in range(0, 8):
row.append(x+y)
plt.text(x, y, "X", horizontalalignment='center', verticalalignment='center', color="white")
img.append(row)
plt.imshow(img)
Upvotes: 1
Reputation: 3272
You can use plt.text
import matplotlib.pyplot as plt
img = []
for x in range(0, 8):
row = []
for y in range(0, 8):
row.append(x+y)
plt.text(x, y, x+y, c='w')
img.append(row)
plt.imshow(img)
plt.show()
Upvotes: 1