mirror of
https://github.com/Estom/notes.git
synced 2026-04-13 14:29:46 +08:00
matplotlib & pandas
This commit is contained in:
63
Python/matplotlab/gallery/scales/scales.md
Normal file
63
Python/matplotlab/gallery/scales/scales.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# 比例尺
|
||||
|
||||
说明应用于轴的比例变换,例如: log,symlog,logit。
|
||||
|
||||

|
||||
|
||||
```python
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.ticker import NullFormatter
|
||||
|
||||
# Fixing random state for reproducibility
|
||||
np.random.seed(19680801)
|
||||
|
||||
# make up some data in the interval ]0, 1[
|
||||
y = np.random.normal(loc=0.5, scale=0.4, size=1000)
|
||||
y = y[(y > 0) & (y < 1)]
|
||||
y.sort()
|
||||
x = np.arange(len(y))
|
||||
|
||||
# plot with various axes scales
|
||||
fig, axs = plt.subplots(2, 2, sharex=True)
|
||||
fig.subplots_adjust(left=0.08, right=0.98, wspace=0.3)
|
||||
|
||||
# linear
|
||||
ax = axs[0, 0]
|
||||
ax.plot(x, y)
|
||||
ax.set_yscale('linear')
|
||||
ax.set_title('linear')
|
||||
ax.grid(True)
|
||||
|
||||
|
||||
# log
|
||||
ax = axs[0, 1]
|
||||
ax.plot(x, y)
|
||||
ax.set_yscale('log')
|
||||
ax.set_title('log')
|
||||
ax.grid(True)
|
||||
|
||||
|
||||
# symmetric log
|
||||
ax = axs[1, 1]
|
||||
ax.plot(x, y - y.mean())
|
||||
ax.set_yscale('symlog', linthreshy=0.02)
|
||||
ax.set_title('symlog')
|
||||
ax.grid(True)
|
||||
|
||||
# logit
|
||||
ax = axs[1, 0]
|
||||
ax.plot(x, y)
|
||||
ax.set_yscale('logit')
|
||||
ax.set_title('logit')
|
||||
ax.grid(True)
|
||||
ax.yaxis.set_minor_formatter(NullFormatter())
|
||||
|
||||
|
||||
plt.show()
|
||||
```
|
||||
|
||||
## 下载这个示例
|
||||
|
||||
- [下载python源码: scales.py](https://matplotlib.org/_downloads/scales.py)
|
||||
- [下载Jupyter notebook: scales.ipynb](https://matplotlib.org/_downloads/scales.ipynb)
|
||||
Reference in New Issue
Block a user