2

I was wondering where and how does matplotlib stores information about plots, titles, labels, and...

In some python libraries, you make an instance of a class, and then modify the atributes or call the methods in order to get the results you want. But for example in matplotlib

plt.plot(x, y)
plt.title('matplotlib')
plt.show()

plot and title are two separated functions, How does show function have access to the returning value of those two functions, and what kind of data structure is involved here?

Amirreza A.
  • 736
  • 4
  • 10
  • Possible duplicate of [How to extract data from matplotlib plot](https://stackoverflow.com/questions/8938449/how-to-extract-data-from-matplotlib-plot) – m13op22 Aug 22 '19 at 18:15
  • Related: [How does plt.show() know what to show?](https://stackoverflow.com/questions/48398923/how-does-plt-show-know-what-to-show/), [Imported pyplot module...](https://stackoverflow.com/questions/57541495/imported-pyplot-module-and-called-pyplot-plot-but-didnt-store-the-return-to-a), [How do plt.plot(x,y) and plt.show() work](https://stackoverflow.com/questions/46450731/how-do-plt-plotx-y-and-plt-show-work-the-way-they-do), [What is state-based interface?](https://stackoverflow.com/questions/52816131/matplotlib-pyplot-documentation-says-it-is-state-based-interface-to-matplotlib) – ImportanceOfBeingErnest Aug 22 '19 at 18:41
  • Also a good read is [The matplotlib API](https://matplotlib.org/api/index.html) and the [canvas agg demo](https://matplotlib.org/gallery/user_interfaces/canvasagg.html#), which is an example for completely object-oriented matplotlib usage. – ImportanceOfBeingErnest Aug 22 '19 at 18:47

1 Answers1

1

According to the Matplotlib documentation:

In matplotlib.pyplot various states are preserved across function calls, so that it keeps track of things like the current figure and plotting area, and the plotting functions are directed to the current axes (please note that "axes" here and in most places in the documentation refers to the axes part of a figure and not the strict mathematical term for more than one axis).

Anoop R Desai
  • 712
  • 5
  • 18