我有一本我想画的字典。我试着在x值处画一条垂直线,其中50%的y值在上面,50%在下面。在
我试图通过找到dict.值(y值)并获取匹配键。但我得到的x值太低了,这显然不是中等x值。有人知道我怎么做吗?以下是我目前所得到的:
hist1, hist2 = np.genfromtxt('./Unfold_Accessibility/social_shortest_path_durations_histogram.txt', unpack=True)
hist = np.genfromtxt('./Unfold_Accessibility/social_shortest_path_durations_histogram.txt')
dl1 = dict(hist)
median1 = dl1.keys()[dl1.values().index(np.median(dl1.values()))]
%matplotlib inline
fig = plt.figure()
ax = fig.add_subplot(111)
plt.plot(hist1, hist2, '-', color='blue', label='data')
ax.axvline(median1, color='blue', linestyle='--', label='mean p=1')
plt.title('Shortest Path Duration Cumulative')
plt.legend(bbox_to_anchor=(1.6, 1))
plt.xlabel('Time')
plt.ylabel('Probability')
plt.grid(True)
plt.show()
^{pr2}$
您需要在遍历键之前对它们进行排序:
例如:
相关问题 更多 >
编程相关推荐