python - 如何放大python中的肘部图?
问题描述
我正在尝试使用技术计算每个点与其 k 最近邻居之间的平均距离并生成 k 距离肘部图,但我不知道如何在图上应用放大以清楚地看到肘部,像这样: 在此处输入图像描述并 在此处输入图像描述
这是我的代码
neighbors = NearestNeighbors(n_neighbors=6)
neighbors_fit = neighbors.fit(data_scale)
distances, indices = neighbors_fit.kneighbors(data_scale)
print(distances)
distances = np.sort(distances, axis=0)
distances = distances[:,1]
plt.plot(distances)
plt.xlabel('Distance')
plt.ylabel('eps')
plt.title('Elbow Method For Optimal eps')
plt.show()
你能帮助我吗?
解决方案
要放大,您可以通过plt.xlim()
和plt.ylim()
例如
plt.xlim([5000, 6000])
plt.ylim([0, 400])
推荐阅读
- python - Python 正则表达式阻塞模式
- python - SPOTIFY API - 抓取多位艺术家
- python - 使用python在缺失数据之间进行插值
- r - 在闪亮的应用程序中使用 2 个动作按钮在 3 个绘图之间切换
- python - 当期权值不断变化时,如何使用硒通过下拉列表进行封闭式?
- python - 更改硒驱动程序时区
- reactjs - How to get context from higher order component in constructor of child component?
- python - How best to store a distribution of values for specific prices?
- caching - How to cache tiles on my server for a leaflet app
- react-native - React Native 中的 UIViewController 没有响应触摸