0

I would you like to add a scrollbar to this app and I can't figure out how to do this. (I am using code from this site https://datatofish.com/matplotlib-charts-tkinter-gui/ ,but I modified a little bit)

from tkinter import *
from pandas import DataFrame

import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

data3 = {'Interest_Rate': [5, 5.5, 6, 5.5, 5.25, 6.5, 7, 8, 7.5, 8.5],
         'Stock_Index_Price': [1500, 1520, 1525, 1523, 1515, 1540, 1545, 1560, 1555, 1565]
         }
df4 = DataFrame(data3, columns=['Interest_Rate', 'Stock_Index_Price'])

# Create a root window
root = Tk()

# Add a bunch of widgets to fill some space
num_rows = 5
for row in range(num_rows):
    figure4 = plt.Figure(figsize=(5, 4), dpi=100)
    ax4 = figure4.add_subplot(111)
    ax4.scatter(df4['Interest_Rate'], df4['Stock_Index_Price'], color='g')
    scatter3 = FigureCanvasTkAgg(figure4, root)
    scatter3.get_tk_widget().grid(row=row, column=0, padx=4, pady=4)
    ax4.legend(['Stock_Index_Priceee'])
    ax4.set_xlabel('Interest Rate')
    ax4.set_title('Interest Rate Vs. Stock Index Price')

    figure4 = plt.Figure(figsize=(5, 4), dpi=100)
    ax4 = figure4.add_subplot(111)
    ax4.scatter(df4['Interest_Rate'], df4['Stock_Index_Price'], color='g')
    scatter3 = FigureCanvasTkAgg(figure4, root)
    scatter3.get_tk_widget().grid(row=row, column=1, padx=4, pady=4)
    ax4.legend(['Stock_Index_Priceee'])
    ax4.set_xlabel('Interest Rate')
    ax4.set_title('Interest Rate Vs. Stock Index Price')


# Start Tk's event loop
root.mainloop()

and it looks like this: https://i.stack.imgur.com/tBFxo.jpg

I would like to see three remaining rows by scrolling down in app. Thanks in advance!

dejwux
  • 1
  • 1

0 Answers0