We Are Going To Discuss About Matplotlib change Figure size. So lets Start this Python Article.
Matplotlib change Figure size
- How to solve Matplotlib change Figure size
with below code, I save the plot with figsize that set before. in your code first set figsize then plot.
in your code try this:figure(figsize = (20, 6), dpi = 80) with plot.style.context('ggplot'): for row in Data: plot.plot(range(len(row)), row) x_axis = ['01-2019', '02-2019', '03-2019', '04-2019', '05-2019', '06-2019', '07-2019', '08- 2019', '09-2019', '10-2019', '11-2019', '12-2019', '01-2020', '02-2020', '03-2020', '04-2020', '05-2020', '06-2020', '07-2020', '08-2020', '09-2020', '10-2020', '11-2020', '12-2020', '01- 2021', '02-2021', '03-2021', '04-2021', '05-2021', '06-2021'] plot.xticks(nump.arange(30), x_axis, rotation = '50') plot.savefig('globalTrafficDuringRoni.png', dpi = 1000)
see this example:import matplotlib.pyplot as plt from matplotlib.pyplot import figure D = {'a':0.1, 'b': 0.2, 'c':0.5, 'd':0.3, 'e':0.4, 'f':0.6, 'g':0.4} figure(figsize = (10, 6), dpi = 80) plt.bar(range(len(D)), list(D.values()), align='center') plt.xticks(range(len(D)), list(D.keys())) plt.savefig('globalTrafficDuringRoni.png', dpi = 1000) plt.show()
output: - Matplotlib change Figure size
with below code, I save the plot with figsize that set before. in your code first set figsize then plot.
in your code try this:figure(figsize = (20, 6), dpi = 80) with plot.style.context('ggplot'): for row in Data: plot.plot(range(len(row)), row) x_axis = ['01-2019', '02-2019', '03-2019', '04-2019', '05-2019', '06-2019', '07-2019', '08- 2019', '09-2019', '10-2019', '11-2019', '12-2019', '01-2020', '02-2020', '03-2020', '04-2020', '05-2020', '06-2020', '07-2020', '08-2020', '09-2020', '10-2020', '11-2020', '12-2020', '01- 2021', '02-2021', '03-2021', '04-2021', '05-2021', '06-2021'] plot.xticks(nump.arange(30), x_axis, rotation = '50') plot.savefig('globalTrafficDuringRoni.png', dpi = 1000)
see this example:import matplotlib.pyplot as plt from matplotlib.pyplot import figure D = {'a':0.1, 'b': 0.2, 'c':0.5, 'd':0.3, 'e':0.4, 'f':0.6, 'g':0.4} figure(figsize = (10, 6), dpi = 80) plt.bar(range(len(D)), list(D.values()), align='center') plt.xticks(range(len(D)), list(D.keys())) plt.savefig('globalTrafficDuringRoni.png', dpi = 1000) plt.show()
output:
Solution 1
with below code, I save the plot with figsize that set before. in your code first set figsize then plot.
in your code try this:
figure(figsize = (20, 6), dpi = 80)
with plot.style.context('ggplot'):
for row in Data:
plot.plot(range(len(row)), row)
x_axis = ['01-2019', '02-2019', '03-2019', '04-2019', '05-2019', '06-2019', '07-2019', '08- 2019', '09-2019', '10-2019', '11-2019', '12-2019', '01-2020', '02-2020', '03-2020', '04-2020', '05-2020', '06-2020', '07-2020', '08-2020', '09-2020', '10-2020', '11-2020', '12-2020', '01- 2021', '02-2021', '03-2021', '04-2021', '05-2021', '06-2021']
plot.xticks(nump.arange(30), x_axis, rotation = '50')
plot.savefig('globalTrafficDuringRoni.png', dpi = 1000)
see this example:
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
D = {'a':0.1, 'b': 0.2, 'c':0.5, 'd':0.3, 'e':0.4, 'f':0.6, 'g':0.4}
figure(figsize = (10, 6), dpi = 80)
plt.bar(range(len(D)), list(D.values()), align='center')
plt.xticks(range(len(D)), list(D.keys()))
plt.savefig('globalTrafficDuringRoni.png', dpi = 1000)
plt.show()
output:
Original Author I’mahdi Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.