Python Forum
Tuple Unpacking with graphs in matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tuple Unpacking with graphs in matplotlib
#3
(Mar-23-2017, 04:51 PM)zivoni Wrote: plt.subplots() returns tuple containg figure object and arrray of axis objects (if atleast one of nrows or ncols is > 1). When you want plot with two subplots in one row, you use fig, axes = plt.subplots(1,2), unpacking assigns figure into fig and axis array into axes. After that you can use axes to access specified subplots, while fig is used to control entire figure. Simple example:
 import numpy as np import matplotlib.pyplot as plt x = np.linspace(-2, 2, 400) fig, axes = plt.subplots(1,2) axes[0].plot(x, x**2) axes[1].plot(x, x**3) fig.savefig('boo.png', dpi=200) 
[Image: OOKQKp8.png]

That was exceedingly helpful. Thank you!
Reply


Messages In This Thread
RE: Tuple Unpacking with graphs in matplotlib - by smw10c - Mar-23-2017, 05:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dynamically plotting graphs with matplotlib CAD79 8 154 1 hour ago
Last Post: deanhystad
  How to plot 2 graphs in one figure? man0s 1 1,358 Apr-25-2022, 09:18 AM
Last Post: Axel_Erfurt
  plotting of graphs mudezda1 2 2,794 Feb-11-2019, 12:44 PM
Last Post: mudezda1

Forum Jump:

User Panel Messages

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