2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -2,7 +2,7 @@
In [1]:
```
```py
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
@@ -22,7 +22,7 @@ import matplotlib.pyplot as plt
调用 `legend()` 会自动获取当前的 `Axes` 对象,并且得到这些 handles 和 labels相当于
```
```py
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles, labels)
```
@@ -31,7 +31,7 @@ ax.legend(handles, labels)
In [2]:
```
```py
line_up, = plt.plot([1,2,3], label='Line 2')
line_down, = plt.plot([3,2,1], label='Line 1')
plt.legend(handles=[line_up, line_down])
@@ -143,7 +143,7 @@ AAAAAElFTkSuQmCC
In [3]:
```
```py
line_up, = plt.plot([1,2,3])
line_down, = plt.plot([3,2,1])
plt.legend([line_up, line_down], ['Line Up', 'Line Down'])
@@ -270,7 +270,7 @@ DBM7ACQMEzsAJAwTOwAkDBM7ACQMEzsAJMz/A0F5tMDKB4A7AAAAAElFTkSuQmCC
In [4]:
```
```py
import matplotlib.patches as mpatches
red_patch = mpatches.Patch(color='red', label='The red data')
@@ -370,7 +370,7 @@ yHCXpAIZ7pJUIMNdkgpkuEtSgQx3SSqQ4S5JBfp/m91y2WTXKGoAAAAASUVORK5CYII=
In [5]:
```
```py
import matplotlib.lines as mlines
import matplotlib.pyplot as plt
@@ -481,7 +481,7 @@ EFOmWk0euQAAAABJRU5ErkJggg==
In [6]:
```
```py
plt.plot([1,2,3], label="test1")
plt.plot([3,2,1], label="test2")
plt.legend(bbox_to_anchor=(1, 1),
@@ -601,7 +601,7 @@ VsmYJAjFAAAAAElFTkSuQmCC
In [7]:
```
```py
plt.subplot(211)
plt.plot([1,2,3], label="test1")
plt.plot([3,2,1], label="test2")
@@ -799,7 +799,7 @@ EZtHunC15QAAAABJRU5ErkJggg==
In [8]:
```
```py
line1, = plt.plot([1,2,3], label="Line 1", linestyle='--')
line2, = plt.plot([3,2,1], label="Line 2", linewidth=4)
@@ -956,7 +956,7 @@ DgApQ2IHgJQhsQNAyvw/a8UJ8l9tWroAAAAASUVORK5CYII=
In [9]:
```
```py
from numpy.random import randn
z = randn(10)
@@ -1127,7 +1127,7 @@ Be7/A4OqIDdoxkFmAAAAAElFTkSuQmCC
In [10]:
```
```py
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
@@ -1251,7 +1251,7 @@ IMNdkgr0v4W1q8xEcgEdAAAAAElFTkSuQmCC
In [11]:
```
```py
from matplotlib.legend_handler import HandlerPatch
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches