我可以使用
绘制CDF图(我的CDF)import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
def to_percent(y, position):
# Ignore the passed in position. This has the effect of scaling the default
# tick locations.
s = str(y)
# The percent symbol needs escaping in latex
if matplotlib.rcParams['text.usetex'] is True:
return s + r'$\%$'
else:
return s + '%'
data = np.loadtxt('histogram.txt')
logdata = np.log(data+1)
num_bins = 50000
counts, bin_edges = np.histogram(logdata, bins=num_bins)
cdf = (np.cumsum(counts)/77824) * 100
plt.plot(bin_edges[1:], cdf)
formatter = FuncFormatter(to_percent)
plt.gca().yaxis.set_major_formatter(formatter)
plt.xlabel('log(No. of ListMemberships + 1)')
plt.ylabel('Cumulative Percentage')
plt.show()
我想做的是在下面添加CDF等附加信息,其中包含一些文本(90%,y轴为10%)以及绘制图中的其他红色虚线。