擅长:python、mysql、java
<p>如果你想定义一个好的或坏的区域,我通常会发现在数据后面放一个补丁更容易让用户理解。在</p>
<pre><code>fig, ax = plt.subplots(figsize=(4, 4))
ax.plot([1,2,3,4], [1,2,3,4], color='blue') # simple example line
# define patch area
rect = patches.Rectangle(
xy=(ax.get_xlim()[0], 2), # lower left corner of box: beginning of x-axis range & y coord)
width=ax.get_xlim()[1]-ax.get_xlim()[0], # width from x-axis range
height=1,
color='green', alpha=0.1, ec='red'
)
ax.add_patch(rect)
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/Lgb0K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lgb0K.png" alt="enter image description here"/></a></p>