mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-28 12:33:06 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
@@ -14,20 +14,20 @@ import numpy as np
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
plt.style.available
|
||||
|
||||
```
|
||||
|
||||
Out[2]:
|
||||
|
||||
```
|
||||
```py
|
||||
[u'dark_background', u'bmh', u'grayscale', u'ggplot', u'fivethirtyeight']
|
||||
```
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
x = np.linspace(0, 2 * np.pi)
|
||||
y = np.sin(x)
|
||||
|
||||
@@ -199,7 +199,7 @@ gg==
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
plt.style.use('ggplot')
|
||||
|
||||
plt.plot(x, y)
|
||||
@@ -397,7 +397,7 @@ wU9EFGT+Pxvu78Bmq8eQAAAAAElFTkSuQmCC
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
with plt.style.context(('dark_background')):
|
||||
plt.plot(x, y, 'r-o')
|
||||
plt.show()
|
||||
@@ -564,7 +564,7 @@ SUVORK5CYII=
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
with plt.style.context(('dark_background')):
|
||||
pass
|
||||
plt.plot(x, y, 'r-o')
|
||||
@@ -764,7 +764,7 @@ YeEnIgoyLPxEREHm/wEVP/FL2qENYwAAAABJRU5ErkJggg==
|
||||
|
||||
In [7]:
|
||||
|
||||
```
|
||||
```py
|
||||
plt.style.use(['dark_background', 'ggplot'])
|
||||
|
||||
plt.plot(x, y, 'r-o')
|
||||
@@ -968,7 +968,7 @@ YeEnIgoyLPxEREHm/wEVP/FL2qENYwAAAABJRU5ErkJggg==
|
||||
|
||||
In [8]:
|
||||
|
||||
```
|
||||
```py
|
||||
import matplotlib
|
||||
matplotlib.get_configdir()
|
||||
|
||||
@@ -976,13 +976,13 @@ matplotlib.get_configdir()
|
||||
|
||||
Out[8]:
|
||||
|
||||
```
|
||||
```py
|
||||
u'c:/Users/Jin\\.matplotlib'
|
||||
```
|
||||
|
||||
里面的内容以 `属性:值` 的形式保存:
|
||||
|
||||
```
|
||||
```py
|
||||
axes.titlesize : 24
|
||||
axes.labelsize : 20
|
||||
lines.linewidth : 3
|
||||
@@ -993,6 +993,6 @@ ytick.labelsize : 16
|
||||
|
||||
假设我们将其保存为 `mpl_configdir/stylelib/presentation.mplstyle`,那么使用这个风格的时候只需要调用:
|
||||
|
||||
```
|
||||
```py
|
||||
plt.style.use('presentation')
|
||||
```
|
||||
Reference in New Issue
Block a user