Files
notes_estom/Python/matplotlab/gallery/scales/symlog_demo.md
2020-09-26 22:03:11 +08:00

41 lines
911 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Symlog演示
示例使用symlog对称对数轴缩放。
![Symlog演示](https://matplotlib.org/_images/sphx_glr_symlog_demo_001.png)
```python
import matplotlib.pyplot as plt
import numpy as np
dt = 0.01
x = np.arange(-50.0, 50.0, dt)
y = np.arange(0, 100.0, dt)
plt.subplot(311)
plt.plot(x, y)
plt.xscale('symlog')
plt.ylabel('symlogx')
plt.grid(True)
plt.gca().xaxis.grid(True, which='minor') # minor grid on too
plt.subplot(312)
plt.plot(y, x)
plt.yscale('symlog')
plt.ylabel('symlogy')
plt.subplot(313)
plt.plot(x, np.sin(x / 3.0))
plt.xscale('symlog')
plt.yscale('symlog', linthreshy=0.015)
plt.grid(True)
plt.ylabel('symlog both')
plt.tight_layout()
plt.show()
```
## 下载这个示例
- [下载python源码: symlog_demo.py](https://matplotlib.org/_downloads/symlog_demo.py)
- [下载Jupyter notebook: symlog_demo.ipynb](https://matplotlib.org/_downloads/symlog_demo.ipynb)