- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在处理汇率数据,结果非常奇怪,图表中出现了未完成的线条。
我已经阅读了不同的示例,遵循了这些示例,但仍然无法摆脱这些线条。
有人知道我的代码有什么问题吗?感谢您的帮助。
df = df[['PRICE', 'TIME']]
start_time = '2018-08-01 19:50:00'
end_time = '2018-08-01 20:10:00'
df = df[(df['TIME'] > start_time) & (df['TIME'] <= end_time)]
df = df.set_index('TIME')
plt.figure(figsize = (18,9))
plt.plot(pd.to_datetime(df.index),df["PRICE"])
plt.xlabel('Time',fontsize=18)
plt.ylabel('Mid Price',fontsize=18)
如果需要任何数据,我将 csv 文件保存在 Google Drive https://drive.google.com/file/d/1ANybvOKeUYIhXxtm97VNT88SI8z2OWjV/view?usp=sharing 中
最佳答案
使用了您提供的相同数据
您需要添加df = df.sort_values(['TIME'], ascending=[True])
代码:
df = df[(df['TIME'] > start_time) & (df['TIME'] <= end_time)]
# df = df.drop_duplicates('TIME')
df = df.sort_values(['TIME'], ascending=[True])
df = df.set_index('TIME')
plt.figure(figsize=(18, 9))
plt.plot(pd.to_datetime(df.index), df["PRICE"])
plt.xlabel('Time', fontsize=18)
plt.ylabel('Mid Price', fontsize=18)
plt.show()
输出:
关于python - pandas 情节时间序列-出现奇怪的线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52217438/
我有这样一个数据框 from datetime import date import random start_date = date.today().replace(day=1, month=1).
我想使用 fiddle 图比较技术化的几个维度的分布(维度由 1 到 5 的指数衡量)。 6 个 fiddle 图中有 5 个看起来与您预期的一样,但其中一个具有未反射(reflect)在数据中的非常
我正在将向量列表绘制为一系列 fiddle 图。我会使用 pandas 数据框,但列表的长度不等。 这有效: python g = sns.violinplot (data=res, cut=0, i
以下代码为我提供了一个非常漂亮的 fiddle 图(以及其中的箱线图)。 import numpy as np import seaborn as sns import matplotlib.pypl
我有以下代码来显示堆叠条 handles = df.toPandas().set_index('x').T.plot(kind='bar', stacked=True, figsize=(11,11)
目前我在 2x2 子图中绘制了 3 个图。它看起来像这样: fig, axes = plt.subplots(nrows=2, ncols=2) df1.plot('type_of_plot', ax
以下代码为我提供了一个非常漂亮的 fiddle 图(以及其中的箱线图)。 import numpy as np import seaborn as sns import matplotlib.pypl
我正在使用带有以下代码的 ggplot 的 python 版本并附加了图像,但颜色不足以为所有类别着色。我想知道有什么方法可以获得具有更多颜色的调色板,但仍然保留较低数字颜色较浅而较高数字颜色较深的关
我正在查看示例,但一切都需要数据框。 如果我有以下数据框: x = ["G","F","E","D","C","B"] y = [3,14,45,47,34,15] df = pd.DataFrame
我有很多数据框正在绘制用于演示。这些都有不同的列,但都包含相同的附加列 foobar。目前,我正在使用绘制这些不同的数据框 df.plot(secondary_y='foobar') 不幸的是,由于这
我无法让 Bokeh 显示我的绘图。这是我的 Python 代码。 import pandas as pd from bokeh.plotting import figure, ColumnDataS
我使用 matplot 库在 python 中绘制绘图。我必须生成的数字非常大,所以轴上的刻度也是很大的数字并且占用大量空间。我试图将它们呈现为幂(例如,我想要 10^8 而不是勾选 10000000
我使用 matplot 库在 python 中绘制绘图。我必须生成的数字非常大,所以轴上的刻度也是很大的数字并且占用大量空间。我试图将它们呈现为幂(例如,我想要 10^8 而不是勾选 10000000
我只想制作一个地毯图,其中每个系列都被绘制为水平的刻度带,类似于所示的图 on this page .我也见过这叫做“光栅图”。地毯图看起来很相似,但看起来 geom_rug 只适用于边距。我可以在
我正在使用此处示例中的代码绘制一个图: http://bl.ocks.org/mbostock/3887118 我是 HTML、CSS 和 JS 的新手,但了解一些基础知识。我想知道如何将绘图置于浏览
有一个 df : import random import pandas as pd def get_row(): row = {"date" : random.choice(range(10
第一个加载的绘图在 X 轴上有太多刻度(参见 image01)。 如果我在 X 轴上使用缩放操作,绘图现在已加载完毕。 你能给我一些建议,我可以在哪里搜索,因为 Plot 构造函数参数看起来不错。 d
我正在尝试为我的情节添加标题,但收到错误消息: "AttributeError: 'Figure' object has no attribute 'update_layout'" 该情节在没有 up
我想在 python 中使用 networkx 绘制有向网络图。当使用不同于 1 的 alpha 值时,边缘的起点也在节点内绘制;但是箭头很好。 如何让边远离我的节点? 我没有在文档中找到任何关于它的
出于视觉效果的目的,我希望我可以删除圆圈外的网格,只保留圆圈内的网格。 顺便说一句,如何用红色填充单元格 ([8,9],[9,10]),我的意思是,x=8 右侧和 y=9 下方的单元格。 我的代码在下
我是一名优秀的程序员,十分优秀!