Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying a Dataframe on a plotly plot

Say I want to display a small one row dataframe on a plot, is this possible?

Example:

    buy_hold    coin    lose.max    no_trades   strat_prof  win.max
0   7.406522    DASH    -2.115741   89.0    270.080641  123.46243

I want the resulting plot to look like this: plot

like image 231
David Hancock Avatar asked Sep 13 '26 10:09

David Hancock


1 Answers

EDIT: I first suggested using Pandas to plot the table, but it can also be done directly with Matplotlib.

Matplotlib has a method for displaying tables in plots, and it can be customized in many ways, see the documentation here.

Here is a plot that looks quite similar to what you want:

enter image description here

The code for the plot:

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()
like image 161
J. P. Petersen Avatar answered Sep 15 '26 00:09

J. P. Petersen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!