1
如果我想將它作爲我的情節中的註釋,如何將spearmanr結果舍入爲小數點後3位?將spearmanr結果舍入爲小數點後3位
import matplotlib.pyplot as plt
import scipy.stats
import numpy as np
percent = np.array([34.72,47.22,40.97,43.06,57.64,50.00,69.44])
year = np.array([2009,2010,2011,2012,2013,2014,2015])
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(year,percent, marker='o')
ax.set_ylim(20,80)
ax.set_xticks(year)
ax.annotate(scipy.stats.spearmanr(year,percent), xy=(2009,70))
plt.show()
Output 我想要的註解留在圖表上。