简体   繁体   English

缩放区域无法正常工作 - Matplotlib

[英]Zoom Region Not Working Properly - Matplotlib

So, I was trying to get a subplot of a region from an plot that should be zoomed in.所以,我试图从应该放大的 plot 中获取一个区域的子图。

Code: (Minimal, Reproducible one)代码:(最小的,可重现的)

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

#Loading Data
data = pd.read_csv("lol.csv")
data.head()

import matplotlib.pyplot as plt
ypoints = np.array(data['KDA'])
xpoints = np.array(data['Win/Lose'])

from mpl_toolkits.axes_grid1.inset_locator import mark_inset, inset_axes
ax = plt.subplot(1, 1, 1)
ax.scatter(xpoints, ypoints)
ax.set_xlabel("Win/Loss")
ax.set_ylabel("KDA")
axins = ax.inset_axes([0.3, 0.3, 0.47, 0.47])
x1, x2, y1, y2 = 0, 0, -0.5, 6.5
axins.set_xlim(x1, x2)
axins.set_ylim(y1, y2)

ax.indicate_inset_zoom(axins, edgecolor="black")

It is showing this:它显示了这一点:

问题

It should show somewhat like this:它应该有点像这样:

可能的解决方案

or somewhat like this: (Collected)或有点像这样:( 收集)

可能的解决方案 2

What should I do now?我现在该怎么办?

Thanks.谢谢。

Solution:解决方案:

I just forgot to adding the scatter function.我只是忘了添加散点图 function。

axins.scatter(xpoints, ypoints)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM