Python Forum
[Tkinter] how to remove black area around the graph in tkinter ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] how to remove black area around the graph in tkinter ?
#1
from tkinter import *
from tkinter import ttk
import numpy as np
import pandas as pd


from pandas_datareader import data as wb
import matplotlib.pyplot as plt

from yahoofinancials import YahooFinancials

from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

import matplotlib 
matplotlib.use('TkAgg')

plt.style.use('dark_background')


class Scr:

    def __init__(self, master):

        master.geometry('900x900+120+60')
        master.configure(background = 'gray9')


        self.style = ttk.Style()
        self.style.theme_use('clam')
        self.style.configure('TFrame',background = 'green')
        
        self.style.configure('TCanvas',background = 'yellow', width=0,height=0,font='serif 10')
        
        self.style.configure('TButton',background = 'blue')
        self.style.configure('TLabel', background = 'pink',font = ('Arial', 15))
        
        
        self.frame_content = ttk.Frame(master)
        self.frame_content.pack()
        
        options = ['AAPL']
        


        m = pd.DataFrame()

        for o in options :
            m[o] = wb.DataReader(o, data_source='yahoo', start='2004-1-1')['Adj Close']

      
        a=m
        
       
        graph2 = ttk.Frame(master)
        graph2.pack()


        fig2 = matplotlib.pyplot.Figure(figsize=(6,6))

        canvas3 = FigureCanvasTkAgg(fig2, graph2)
       
        canvas3.get_tk_widget().grid(padx=0, pady=0,sticky="nswe")
        ax3 = fig2.add_subplot(211)

        a.plot(kind='line', legend=True, ax=ax3, color='blue') 
    

def main():
    root = Tk()
    scr = Scr(root)
    root.mainloop()

if __name__ == "__main__":
    main()
Reply
#2
I will appreciate any suggestion as I am new in programming and would like to understand what I am doing wrong
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Tkinter Matplotlib Animation Graph not rendering dimidgen 3 335 Mar-12-2024, 02:09 PM
Last Post: deanhystad
  [Tkinter] TKinter Remove Button Frame Nu2Python 8 812 Jan-16-2024, 06:44 PM
Last Post: rob101
  Tkinter - How can I remove the background borders from ttk.Button? TurboC 4 16,766 Oct-18-2020, 10:58 AM
Last Post: TurboC
  [PyQt] QPainter issue showing black screen mart79 0 1,949 May-06-2020, 12:02 PM
Last Post: mart79
  Axis lim and Plotting a graph in Tkinter KEDivergente 0 1,689 May-21-2019, 08:10 PM
Last Post: KEDivergente
  Tkinter - Make changes to graph and update it adriancovaci 0 6,531 Apr-08-2019, 09:02 AM
Last Post: adriancovaci
  Remove duplicate images - tkinter? darter 5 5,285 Nov-10-2018, 10:54 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020