python - seaborn 散点图绘制的日期比原始数据中的日期多
问题描述
我的数据集包含 2018 年的数据。我尝试绘制一个简单的散点图,出于某种原因,绘制了 2000 年至 2018 年的 seaborn 图。我还没有找到解决方案。
seaborn lineplot 作品。
Matplotlib scatter 也可以正常工作。
代码:
plt.figure(figsize = (7,7), dpi = 200)
sns.scatterplot(x = df["Date"].values,
y = df["values"].values)
plt.show()
解决方案
.set()
您可以使用绘图手动设置 x 轴的范围。
ax = sns.scatterplot(x = df["Date"].values, y = df["values"].values)
ax.set(xlim = ('2018-01-01', '2018-12-31'))
推荐阅读
- julia - 结束,矩阵的 Julia 问题
- package - Mac 上的 LateX:Texmaker 找不到已安装的软件包
- python - 调整大小不会影响 PyQt5 中的布局
- linux - 解释 shell 变量的问题
- selenium - Selenium 等待可点击 - 元素点击被拦截问题
- javascript - 比较两个数组并在 JS 中显示错误索引
- html - 为什么我的特定选择器不适用于 nth-of-type() 和 nth-child()?
- javascript - TypeError: undefined is not an object (评估 'this.state.googleResponse.responses[0]')
- go - 如何从像 javadoc 这样的 Go 项目生成 html 文档?
- django - 即使对于 django 中的登录用户,主视图也会不断重定向到登录页面