Figure size in matplotlib is not changing

39 views Asked by At

I want my graph to have equal scale in x and y axis when I zoom in with the navigation tools, but also bigger at the same time.

ax = plt.gca()
ax.set_xlim([-20,20])
ax.set_ylim([-20,20])
ax.set_aspect('equal', adjustable='box', anchor='C')
plt.grid(True)
plt.show()

However, even when I added

plt.rcParams['figure.figsize'] = (15,15)

or

plt.figure(figsize=(15, 15))

the size of the figure still stays the same.

I have also tried removing the

ax.set_aspect('equal', adjustable='box', anchor='C')

but then when I zoom in, the scale is inproportional

I have tried removing

ax.set_xlim([-20,20])
ax.set_ylim([-20,20])

but then it just doesn't work

Edit: My program is a graphing calculator that generates graph from a user input

import matplotlib.pyplot as plt
import numpy as np

print("y = Ax^(4) + Bx^(3) + Cx^(2) + Dx + E")
list1 = [] 
for i in range(5):
    letter = chr(65+i)
    msg = letter + " = "
    userInput = input(msg)
    userInput = int(userInput)
    list1.append(userInput) #saving user input
x = np.linspace(-100, 100, 100000)
function = int(list1[0]) * x**4 + int(list1[1]) * x**3 + int(list1[2]) * x**2 + int(list1[3]) * x + int(list1[4])

plt.plot(x, function)

I tried calling plt.figure(figsize=(15, 15)) before ax = plt.gca() or call fig, ax = plt.subplots(figsize=(15, 15)) but then two graphs are generated in 2 separated windows.

I believe my question is not a duplicate because I have searched the same question in the site and I can't find one that mentions both scaling and size. I have also tried all solutions mentioned in the questions resolving figure size, but they didn't work for me

0

There are 0 answers