4-2 风格设置

In [1]:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
In [2]:
plt.style.available#可以调用的风格
Out[2]:
['bmh',
 'classic',
 'dark_background',
 'fast',
 'fivethirtyeight',
 'ggplot',
 'grayscale',
 'seaborn-bright',
 'seaborn-colorblind',
 'seaborn-dark-palette',
 'seaborn-dark',
 'seaborn-darkgrid',
 'seaborn-deep',
 'seaborn-muted',
 'seaborn-notebook',
 'seaborn-paper',
 'seaborn-pastel',
 'seaborn-poster',
 'seaborn-talk',
 'seaborn-ticks',
 'seaborn-white',
 'seaborn-whitegrid',
 'seaborn',
 'Solarize_Light2',
 'tableau-colorblind10',
 '_classic_test']
In [5]:
x=np.linspace(-10,10)#在指定的间隔内返回均匀间隔的数字。且默认包括结束点,默认50个样本
y=np.sin(x)
plt.plot(x,y)
Out[5]:
[<matplotlib.lines.Line2D at 0x161b6f98>]
 
 

1.设置风格

In [6]:
plt.style.use('dark_background')#风格设置
plt.plot(x,y)
Out[6]:
[<matplotlib.lines.Line2D at 0x166eb198>]
 
In [9]:
plt.style.use('fivethirtyeight')
plt.plot(x,y)
Out[9]:
[<matplotlib.lines.Line2D at 0x177abeb8>]
 
 

2.混合风格

In [11]:
plt.style.use(['fivethirtyeight','dark_background'])#混合风格
plt.plot(x,y)
Out[11]:
[<matplotlib.lines.Line2D at 0x1783c240>]
 
 

3.xkcd模式:漫画风格

In [20]:
plt.xkcd()
plt.plot(np.sin(np.linspace(0, 10)))
plt.title('Whoo Hoo!!!')
Out[20]:
Text(0.5, 1.0, 'Whoo Hoo!!!')
 

猜你喜欢

转载自www.cnblogs.com/AI-robort/p/11740356.html
4-2
今日推荐