Matplotlib是Python中的一個庫,它是數字的-NumPy庫的數學擴展。 Pyplot是Matplotlib模塊的基於狀態的接口,該模塊提供了MATLAB-like接口。在Pyplot中可以使用各種圖,例如線圖,輪廓圖,直方圖,散點圖,3D圖等。
matplotlib.pyplot.rcdefaults()函數
matplotlib庫的pyplot模塊中的rcdefaults()函數用於從Matplotlib的內部默認樣式中還原rc參數。
用法: matplotlib.pyplot.rcdefaults()
參數:此方法不接受任何參數。
返回:此方法不返回任何值。
以下示例說明了matplotlib.pyplot中的matplotlib.pyplot.rcdefaults()函數:
範例1:
# implementation of the matplotlib function
import matplotlib.pyplot as plt
plt.subplot(211)
plt.rc('font', weight ='bold')
plt.rc('xtick.major', size = 5, pad = 7)
plt.rc('xtick', labelsize = 15)
plt.plot([1, 2, 3])
plt.text(0.4, 3.5, 'matplotlib.pyplot.rcdefaults() Example')
plt.rcdefaults()
plt.subplot(212)
plt.plot([1, 2, 3])
plt.grid(True)
plt.show()
輸出:
範例2:
# implementation of the matplotlib function
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(19680801)
plt.rcdefaults()
fig, ax = plt.subplots()
people = ('Geek1', 'Geek2', 'Geek3', 'Geek4', 'Geek5')
y_pos = np.arange(len(people))
performance = 3 + 5 * np.random.rand(len(people))
error = np.random.rand(len(people))
ax.bar(y_pos, performance, xerr = error, align ='center')
ax.set_yticks(y_pos)
ax.set_yticklabels(people)
ax.invert_yaxis()
plt.grid(True)
plt.title('matplotlib.pyplot.rcdefaults() Example')
plt.show()
輸出:
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 Matplotlib.pyplot.rcdefaults() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。