Ok, so based on NK_ help and the content available in:
Matplotlib- Creating a table with line plots in cells?
I managed to put this together:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
df = pd.DataFrame({'Name':["A","B","C","E","F"],'current':[3,4,7,6,6], 'minimum':[1,3,2,4,1], 'maximum':[10,14,11,7,10], 'average':[8,5,9,5,3]})
data = np.random.rand(100,5)
col1 = df["Name"]
col2 = df["current"]
col2colors = ["red", "g", "r", "r", "r"]
col3 = df["average"]
finalsc = "D+"
fig, axes = plt.subplots(ncols=5, nrows=5, figsize=(6,2.6),
gridspec_kw={"width_ratios":[1,1,1,3,3]})
fig.subplots_adjust(0.05,0.05,0.95,0.95, wspace=0.02, hspace=0.05) #wspace, hspace --> bordi interni grigi della tabella
for ax in axes.flatten():
ax.tick_params(labelbottom=0, labelleft=0, bottom=0, top=0, left=0, right=0)
ax.ticklabel_format(useOffset=False, style="plain")
for _,s in ax.spines.items():
s.set_visible(True)
border = fig.add_subplot(111)
border.tick_params(labelbottom=0, labelleft=0, bottom=0, top=0, left=0, right=0)
border.set_facecolor("None")
text_kw = dict(ha="center", va="bottom", size=15)
for i,ax in enumerate(axes[:,0]):
ax.text(0.5, 0.2, col1[i], transform=ax.transAxes, **text_kw)
for i,ax in enumerate(axes[:,1]):
ax.text(0.5, 0.2, "{:.2f}".format(col2[i]),transform=ax.transAxes, **text_kw)
ax.set_facecolor(col2colors[i])
ax.patch.set_color(col2colors[i])
for i,ax in enumerate(axes[:,2]):
ax.text(0.5, 0.2, "{:.2f}".format(col3[i]),transform=ax.transAxes, **text_kw)
for i,ax in enumerate(axes[:,3]):
ax.plot(data[:,i], color="green", linewidth=1)
for i,ax in enumerate(axes[:,4]):
ax.plot([df['minimum'][index],df['maximum'][index]],[0,0],zorder=0)
ax.scatter(df['current'][index],0,zorder=1)
ax.scatter(df['average'][index],0,zorder=2)
plt.show()
To be fully honest, I don't know if the code I put together is the best code I could have used, there are many parts I still have to understand.
Pleas, the last question I would have is:
could somebody help me to add to this table a first "row" in which we show in bold the titles of each column?
Thanks