坐标报告#

在交互式后端中,当鼠标在轴(Axes)上移动时,覆盖坐标的默认报告方式。

coords report
import matplotlib.pyplot as plt
import numpy as np


def millions(x):
    return '$%1.1fM' % (x * 1e-6)


# Fixing random state for reproducibility
np.random.seed(19680801)

x = np.random.rand(20)
y = 1e7 * np.random.rand(20)

fig, ax = plt.subplots()
ax.fmt_ydata = millions
plt.plot(x, y, 'o')

plt.show()

由 Sphinx-Gallery 生成的画廊