user2242044
user2242044

Reputation: 9213

Changing Chart Size in Matplotlib

I would like to be able to change the size of a chart in matplotlib. I have so far only been able to change the size of the window, but not the chart. I haven't been able to locate anything about this in documentation.

My Code so far:

import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = 5,2

Upvotes: 0

Views: 703

Answers (1)

Ajean
Ajean

Reputation: 5659

You don't need to modify your rcParams if you don't want to, you can pass the figsize as a keyword when you make the figure. For changing the size of the Axes (I believe that's what you mean by 'chart'), the position keyword is what you're looking for if you use add_subplot, or just the input parameter if you use add_axes. You specify it as [left, bottom, width, height]. The relevant documentation is here.

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(5,2))
ax = fig.add_subplot(111, position=[0.01, 0.01, 0.98, 0.98])

Upvotes: 1

Related Questions