Python 2.7 在matplot格式中,坐标仅需显示绘图的x y坐标
在Matplotlib中,如果鼠标悬停在图形画布上的任何位置,format_coord将显示x和y坐标。当鼠标指针位于曲线上方时,如何限制显示仅显示坐标Python 2.7 在matplot格式中,坐标仅需显示绘图的x y坐标,python-2.7,matplotlib,Python 2.7,Matplotlib,在Matplotlib中,如果鼠标悬停在图形画布上的任何位置,format_coord将显示x和y坐标。当鼠标指针位于曲线上方时,如何限制显示仅显示坐标 from matplotlib.axes import Axes class MyAxes(Axes): name = 'MyAxes' def format_coord(self, x, y): # Massage your data here -- good place for scalar multip
from matplotlib.axes import Axes
class MyAxes(Axes):
name = 'MyAxes'
def format_coord(self, x, y):
# Massage your data here -- good place for scalar multiplication
return 'time=%s Damped oscillation=%s' % (x, y)
from matplotlib.projections import projection_registry
projection_registry.register(MyAxes)
import numpy as np
import matplotlib.pyplot as plt
x1 = np.linspace(0.0, 5.0)
x2 = np.linspace(0.0, 2.0)
y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
y2 = np.cos(2 * np.pi * x2)
plt.subplot(2, 1, 1, projection="MyAxes")
plt.plot(x1, y1, 'ko-')
plt.title('Oscillation')
plt.ylabel('Oscillation')
plt.show()
请给我们看看你的护照code@ali_m我已经添加了代码,你知道吗?