

# https://www.globalsino.com/ICs/
# Heatmap

import numpy as np
import matplotlib
import matplotlib as mpl
import matplotlib.pyplot as plt

theTable = ["cuc", "toma", "tuce", "agus", "poto", "heat", "bar"]
farmers = ["Far", "Upla", "Smi", "Agn", "Org", "Bio", "Cor"]

Farms = np.array([[2, 4, 5, 9, 0, 4, 0],
                    [4, 0, 4, 1, 7, 0, 0],
                    [1, 4, 8, 4, 9, 4, 0],
                    [6, 0, 3, 0, 3, 2, 0],
                    [7, 7, 6, 6, 2, 6, 0],
                    [3, 2, 0, 4, 0, 2, 5],
                    [1, 2, 0, 4, 0, 9, 6]])

print(Farms)

fig, ax = plt.subplots()
im = ax.imshow(Farms)

# axis on top of the image
ax.xaxis.tick_top()
# 7 columns
plt.xticks(np.arange(7) + .5, labels=farmers)

# Show all ticks and label them with the respective list entries
ax.set_xticks(np.arange(len(farmers)), labels=farmers)
ax.set_yticks(np.arange(len(theTable)), labels=theTable)

# Rotate the tick labels and set their alignment.
plt.setp(ax.get_xticklabels(), rotation=0, ha="right", rotation_mode="anchor")

# Create text annotations for data loop
for i in range(len(theTable)):
    for j in range(len(farmers)):
        text = ax.text(j, i, Farms[i, j],
                       ha="center", va="center", color="r")

ax.set_title("Farms")
fig.tight_layout()
plt.show()
