简体   繁体   中英

Why does this object display function even if I haven't explicitly used plt.show function?

z = plt.subplots(2,2)
z

Then the output is as follows :

>> (<matplotlib.figure.Figure at 0x28409ef3a90>,
 array([[<matplotlib.axes._subplots.AxesSubplot object at 0x0000028409F810B8>,
         <matplotlib.axes._subplots.AxesSubplot object at 0x000002840A163B00>],
        [<matplotlib.axes._subplots.AxesSubplot object at 0x000002840A1D71D0>,
         <matplotlib.axes._subplots.AxesSubplot object at 0x000002840A237518>]], dtype=object))

Since z[0] is an Figure object, I expected <matplotlib.figure.Figure at 0x28409ef3a90> to be the output if I run z[0] . But it displays 2x2 plot even if I haven't used display.show() explicitly! Why does such thing happen?

iPython outputs the repr value of the object z in the output space.
in this case, a matplotlib Figure object.

iPython does this when the last line executed is simply the object (not an assignment)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM