mirror of
https://github.com/Estom/notes.git
synced 2026-04-13 18:00:27 +08:00
matplotlib & pandas
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# Dashpoint标签
|
||||
|
||||

|
||||
|
||||
```python
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
DATA = ((1, 3),
|
||||
(2, 4),
|
||||
(3, 1),
|
||||
(4, 2))
|
||||
# dash_style =
|
||||
# direction, length, (text)rotation, dashrotation, push
|
||||
# (The parameters are varied to show their effects, not for visual appeal).
|
||||
dash_style = (
|
||||
(0, 20, -15, 30, 10),
|
||||
(1, 30, 0, 15, 10),
|
||||
(0, 40, 15, 15, 10),
|
||||
(1, 20, 30, 60, 10))
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
(x, y) = zip(*DATA)
|
||||
ax.plot(x, y, marker='o')
|
||||
for i in range(len(DATA)):
|
||||
(x, y) = DATA[i]
|
||||
(dd, dl, r, dr, dp) = dash_style[i]
|
||||
t = ax.text(x, y, str((x, y)), withdash=True,
|
||||
dashdirection=dd,
|
||||
dashlength=dl,
|
||||
rotation=r,
|
||||
dashrotation=dr,
|
||||
dashpush=dp,
|
||||
)
|
||||
|
||||
ax.set_xlim((0, 5))
|
||||
ax.set_ylim((0, 5))
|
||||
|
||||
plt.show()
|
||||
```
|
||||
|
||||
## 下载这个示例
|
||||
|
||||
- [下载python源码: dashpointlabel.py](https://matplotlib.org/_downloads/dashpointlabel.py)
|
||||
- [下载Jupyter notebook: dashpointlabel.ipynb](https://matplotlib.org/_downloads/dashpointlabel.ipynb)
|
||||
Reference in New Issue
Block a user