2016-02-10 63 views
1

对于缺乏更好的词,是有办法来标注与图中的数据点?我包括我什么下方对应于它的图形注释数据点与图

大黑数据点的例子。请注意,图表是旋转的,因此其“x”轴(未显示)垂直于散点图的“y”轴。

annotation_box http://matplotlib.org/examples/pylab_examples/demo_annotation_box.html是我目前可以找到的最接近的东西,但即使知道正确的术语什么我想做的事情,就会使我的生活更轻松。

回答

4

如果我理解正确的问题,你需要的是浮动的,你可以将作为您的情节注解轴。不幸的是,这是不是在matplotlib容易实现,因为据我所知。

一个简单的解决方案是将点和图形绘制在同一个轴上,并将图形缩小并靠近点。

import numpy as np 
import scipy.stats as sps 
import matplotlib.pyplot as plt 

xp = [5, 1, 3] 
yp = [2, 1, 4] 

# just generate some curves 
curves_x = np.array([np.linspace(0, 10, 100)] * 3) 
curves_y = sps.gamma.pdf(curves_x[0], [[2], [5], [7]], 1) 

plt.scatter(xp, yp, s=50) 

for x, y, cx, cy in zip(xp, yp, curves_x, curves_y): 
    plt.plot(x + cy/np.max(cy) + 0.1 , y + cx/np.max(cx) - 0.5) 

plt.show() 

enter image description here

这是一个非常简单的例子。这些数字将不得不调整来寻找具有不同的数据的规模不错。