简体   繁体   English

Jupyter Notebook 图表的比例非常不准确?

[英]Jupyter Notebook graph has very inaccurate scale?

this is my first post and I hope it's okay.这是我的第一篇文章,我希望没问题。 My mentor gave me a use case he found online to teach me machine learning on Jupyter.我的导师给了我一个他在网上找到的用例,教我在 Jupyter 上进行机器学习。 I had a problem with the graphing section, even though I'm sure the code in that part is accurate:我的绘图部分有问题,即使我确定那部分的代码是准确的:

df21.plot(figsize=(20,10), fontsize=12,subplots=True, style=["-","o"], title = "Pump 2 - 100 Values")
plt.show() 

The graphs seems to appear as two points or a single straight line, even though the df21 dataset I'm using has 100 lines, and the values are not binary:这些图表似乎显示为两个点或一条直线,即使我使用的 df21 数据集有 100 条线,并且这些值不是二进制的:

Graphs just look like straight lines图表看起来就像直线

Screenshot of the use case用例截图

I tried changing format to just plots and found that the points are actually all there, the scale of the axes is just incredibly squished:我尝试将格式更改为仅绘图,发现这些点实际上都在那里,轴的比例令人难以置信地被压扁:

Graph with only plots仅包含图的图形

And I have no idea what to do now, and I haven't been able to find any solutions online.而且我现在不知道该怎么办,也无法在网上找到任何解决方案。 Any advice is appreciated!任何建议表示赞赏!

After going through the use case you added and trying the code myself i did not find any problem with the plot section.在完成您添加的用例并亲自尝试代码后,我没有发现 plot 部分有任何问题。 probably there is a problem with you parts before plotting.在绘图之前,您的零件可能存在问题。 This is the code from the use case :这是来自用例的代码:

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt

df = pd.read_csv('https://raw.githubusercontent.com/sa-mw-dach/manuela-dev/master/ml-models/anomaly-detection/raw-data.csv')
df['time'] = pd.to_datetime(df['ts'], unit='ms')
df.set_index('time', inplace=True)
df.drop(columns=['ts'], inplace=True)

df21 = df.head(200)
df21.plot(figsize=(20,10), fontsize=12, subplots=True, style=["-","o"], title = "Pump 2 - 100 Values")
plt.show() 

And this is the output:这是 output:

在此处输入图像描述

Maybe try a different environment to run your notebook i tried running it on google colab.也许尝试一个不同的环境来运行你的笔记本,我尝试在 google colab 上运行它。

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

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