📜  Python中的 Matplotlib.pyplot.fill()函数

📅  最后修改于: 2022-05-13 01:55:05.693000             🧑  作者: Mango

Python中的 Matplotlib.pyplot.fill()函数

Matplotlib.pyplot.fill()函数用于填充多边形/曲线包围的区域。

示例 1:

Python3
# Importing the library
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
  
# Data for plotting
x = np.arange(0.0, 2.0, 0.01)
y = 1 + np.sin(2 * np.pi * x)
plt.plot(x, y)
  
# Assighning plot attributes
plt.xlabel("angle")
plt.ylabel("sine")
plt.title('sine wave')
  
# Filling sign wave curv with cyan color
plt.fill(x, y, "c")
plt.show()


Python3
# Importing libraries
import matplotlib
import matplotlib.pyplot as plt
  
  
# Below we are using data attribute
plt.fill("j", "k", 'm',
         data={"j": [0, 1, 2],
               "k": [0, 1, 0]})  # here 'm' for magenta


输出:

示例 1_Output_GFG

示例 2:

蟒蛇3

# Importing libraries
import matplotlib
import matplotlib.pyplot as plt
  
  
# Below we are using data attribute
plt.fill("j", "k", 'm',
         data={"j": [0, 1, 2],
               "k": [0, 1, 0]})  # here 'm' for magenta

输出:

示例 2_Output_GFG