在绘图上显示数据框
Displaying a Dataframe on a plotly plot
假设我想在绘图上显示一个小的单行数据框,这可能吗?
示例:
buy_hold coin lose.max no_trades strat_prof win.max
0 7.406522 DASH -2.115741 89.0 270.080641 123.46243
编辑:我首先建议使用Pandas绘制table,但也可以直接使用Matplotlib来完成。
Matplotlib 有一种在绘图中显示 tables 的方法,并且可以通过多种方式对其进行自定义,请参阅文档 here。
这是一个看起来与您想要的非常相似的情节:
剧情代码:
import numpy as np
import matplotlib.pyplot as plt
plot([1, 3], [40, 60])
plot([2, 4], [40, 60])
ylim(37, 60)
columns = ["buy_hold", "coin", "lose.max", "no_trades", "strat_prof", "win.max"]
cell_text = [["7.406522", "DASH", "-2.115741", "89.0", "270.080641", "123.46243"]]
# Add a table at the bottom of the axes
the_table = plt.table(cellText=cell_text,
colLabels=columns,
colWidths=[.15]*len(columns),
loc='lower right')
# Adjust layout to make room for the table:
#plt.subplots_adjust(bottom=0.3)
plt.show()
假设我想在绘图上显示一个小的单行数据框,这可能吗?
示例:
buy_hold coin lose.max no_trades strat_prof win.max
0 7.406522 DASH -2.115741 89.0 270.080641 123.46243
编辑:我首先建议使用Pandas绘制table,但也可以直接使用Matplotlib来完成。
Matplotlib 有一种在绘图中显示 tables 的方法,并且可以通过多种方式对其进行自定义,请参阅文档 here。
这是一个看起来与您想要的非常相似的情节:
剧情代码:
import numpy as np
import matplotlib.pyplot as plt
plot([1, 3], [40, 60])
plot([2, 4], [40, 60])
ylim(37, 60)
columns = ["buy_hold", "coin", "lose.max", "no_trades", "strat_prof", "win.max"]
cell_text = [["7.406522", "DASH", "-2.115741", "89.0", "270.080641", "123.46243"]]
# Add a table at the bottom of the axes
the_table = plt.table(cellText=cell_text,
colLabels=columns,
colWidths=[.15]*len(columns),
loc='lower right')
# Adjust layout to make room for the table:
#plt.subplots_adjust(bottom=0.3)
plt.show()