I am able to place the table on the right, but it turns out the table could not display completely. I try to use ax, ax_table=plt.subplots()
but it does not go well.
I try to use the "bbox" in the table but I don't quite understand the meaning after I search the Internet.
How do I modify the position of a table and place it on the upper right of the plot (outside the plot)?
import csv
x1=["2018-08-27 15:21:49","2018-08-27 15:21:52","2018-08-27 15:21:53","2018-08-27 15:21:56"]
y1=["5523","3512","6732","3383"]
L=[]
with open("test.csv") as f:
reader=csv.reader(f)
for row in reader:
print(row)
L.append(row)
print(L)
fig,ax=plt.subplots()
plt.subplots_adjust(left=0.2, bottom=0.25)
col_lables=['tiestamp','loadingtime']
# row_lables=['row1','row2','row3']
table_val=L
row_colors=['red','gold','green']
##bbox=[left, bottom, width, height]
my_table=plt.table(cellText=table_val,colWidths=[0.3]*5,colLabels=col_lables,
colColours=row_colors,loc='right')
plt.title("Static Graph & Table")
x11=[datetime.strptime(d,"%Y-%m-%d %H:%M:%S") for d in x1]
y11=[float(i) for i in y1]
date_format=mdates.DateFormatter("%Y-%m-%d %H:%M:%S")
ax.xaxis.set_major_formatter(date_format)
ax.xaxis.set_major_locator(mdates.DayLocator())
plt.xlabel("Date")
plt.ylabel("Loading time")
plt.plot(x11,y11)
ax.yaxis.set_ticks(y11)
ax.xaxis.set_ticks(x11)
plt.gcf().autofmt_xdate()
# plt.grid()
plt.show()