I am very curious to know how seaborn changes the behavior of matplotlib functions by just import seaborn as sns
.
I want to realize the same function to change the behavior of imshow() function in pyplot, for example, i want to show the pixel value at the figure's low left corner.
It is of course possible to just redefine the imshow() function, and import the redefined ones, but the thing is I have multiple scripts that calls imshow() in many different ways, e.g., plt.imshow()
, imshow()
, and the OOP style axes.imshow()
. Is there a simple way to do this like seaborn does?
Read seaborn's source code would of course give me some clue if I have the time luxury ...
Seaborn does not change the behavior of matplotlib functions in the way you describe. Matplotlib exposes a number of options for customization that take effect by changing the default values of various plot parameters. When seaborn is imported, it runs some code that uses this functionality to change the global defaults.
There is an important distinction between changing default parameter values and altering the behavior of functions. What you are proposing is the latter, and it is sometimes called monkey patching. It is possible, but it would be different than what seaborn is doing, and it isn't something I would recommend in any kind of production environment.