Issue
I just learn how to use matplotlib in python.I want to know the diffence of plot set use or not use 'patch'.I have tried the bellow code ,from the pics they seem no differences.
import matplotlib.pyplot as plt
fig1=plt.figure(dpi=500,figsize=(10,10))
sub=fig1.add_subplot(2,2,1)
sub.patch.set_facecolor('green')
plt.show()
import matplotlib.pyplot as plt
fig1=plt.figure(dpi=500,figsize=(10,10))
sub=fig1.add_subplot(2,2,1)
sub.set_facecolor('green')
plt.show()
I have searched google but i find some people use patch while others not ,they don't why. I want to know the difference and how to use both forms. Thanks a lot!
Solution
There is no difference. Axes.set_facecolor
gives you a shortcut to Axes.patch.set_facecolor
:
From matplotlib/axes/_base.py:
def set_facecolor(self, color):
"""
Set the facecolor of the Axes.
Parameters
----------
color : color
"""
self._facecolor = color
self.stale = True
return self.patch.set_facecolor(color)
Note: Axes
is an Artist
subclass
From the documentation, click on the [source]
button.
Answered By - Corralien
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.