mirror of
https://github.com/Estom/notes.git
synced 2026-02-06 12:04:05 +08:00
37 lines
787 B
Markdown
37 lines
787 B
Markdown
# X图
|
|
|
|
添加线条到图形(没有轴)。
|
|
|
|
```python
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.lines as lines
|
|
|
|
|
|
fig = plt.figure()
|
|
|
|
l1 = lines.Line2D([0, 1], [0, 1], transform=fig.transFigure, figure=fig)
|
|
|
|
l2 = lines.Line2D([0, 1], [1, 0], transform=fig.transFigure, figure=fig)
|
|
|
|
fig.lines.extend([l1, l2])
|
|
|
|
plt.show()
|
|
```
|
|
|
|

|
|
|
|
## 参考
|
|
|
|
此示例中显示了以下函数,方法,类和模块的使用:
|
|
|
|
```python
|
|
import matplotlib
|
|
matplotlib.pyplot.figure
|
|
matplotlib.lines
|
|
matplotlib.lines.Line2D
|
|
```
|
|
|
|
## 下载这个示例
|
|
|
|
- [下载python源码: fig_x.py](https://matplotlib.org/_downloads/fig_x.py)
|
|
- [下载Jupyter notebook: fig_x.ipynb](https://matplotlib.org/_downloads/fig_x.ipynb) |