📌  相关文章
📜  Python中的 Matplotlib.figure.Figure.show()

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

Python中的 Matplotlib.figure.Figure.show()

Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 figure 模块提供了顶级 Artist,即 Figure,其中包含所有绘图元素。该模块用于控制所有绘图元素的子图和顶级容器的默认间距。

matplotlib.figure.Figure.show() 方法

matplotlib 库的show() 方法图形模块用于显示图形窗口。

下面的示例说明了 matplotlib.figure 中的 matplotlib.figure.Figure.show()函数:

示例 1:

# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
  
   
fig = plt.figure()
x = np.arange(20) / 50
y = (x + 0.1)*2
   
val1 = [True, False] * 10
val2 = [False, True] * 10
   
plt.errorbar(x, y, 
             xerr = 0.1,
             xlolims = True,
             label ='Line 1')
y = (x + 0.3)*3
   
plt.errorbar(x + 0.6, y,
             xerr = 0.1,
             xuplims = val1,
             xlolims = val2,
             label ='Line 2')
   
y = (x + 0.6)*4
plt.errorbar(x + 1.2, y,
             xerr = 0.1,
             xuplims = True,
             label ='Line 3')
   
plt.legend()
  
fig.suptitle("""matplotlib.figure.Figure.show()
function Example\n\n""", fontweight ="bold") 
  
fig.show() 

输出:

示例 2:

# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
  
   
x = np.linspace(0, 10, 500)
y = np.sin(x**2)+np.cos(x)
   
fig, ax = plt.subplots()
   
ax.plot(x, y, label ='Line 1')
   
ax.plot(x, y - 0.6, label ='Line 2')
   
ax.legend()
  
fig.suptitle("""matplotlib.figure.Figure.show()
function Example\n\n""", fontweight ="bold") 
  
fig.show() 

输出: