2016-02-10 62 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

這是一個非常簡單的例子。這些數字將不得不調整來尋找具有不同的數據的規模不錯。