Gardener85
Gardener85

Reputation: 369

Tkinter window changes dimensions or resolution when I use pyplot

First time posting, but have found these forums incredibly helpful with my python learning!

I have a problem when I call plt.plot as it's resizing my tkinter window. I've tried this in python 2.7 and 3.5 both seem to have the issue.

Below is just some sample code to re-create the problem. You don't even need to show the graph for this problem to be re-created as soon as you plot the data it resizes.

Before

After

from tkinter import *
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
master = Tk() 
def plotting():
    plt.plot(x)
    #plt.show()



master.minsize(width=450, height=600)
master.wm_title("Tester")

#
y = Button(master, text='START', command=plotting )
y.place(x=230, y=180)

master.mainloop()

Upvotes: 1

Views: 916

Answers (2)

Ricardo
Ricardo

Reputation: 691

In stead of using plt.plot(x), you might want to use plt.Figure() first. To be more specific, plotting() function can be constructed as follows.

def plotting():
    fig = plt.Figure()
    ax = fig.add_subplot()
    ax.plot(x)

Then, you can work on fig to realize the functions.

Upvotes: 0

Gardener85
Gardener85

Reputation: 369

Under windows customize display there's a scrollbar for: "Change the size of text, apps and other items: 150% (Recommended)"

When I changed that to 100% the tkinter window no longer resizes.

Thank you @R.p.T for trying to assist me!

Upvotes: 1

Related Questions