我創建了6個不同的數據框,可消除其原始數據框的異常值。現在,我試圖繪製所有消除同一圖表上異常值的數據框。在一個圖中繪製多個熊貓數據框
這是我的代碼,消除了在每個數據幀中的異常值:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.style.use("ggplot")
#---Original DataFrame
x = (g[0].time[:27236])
y = (g[0].data.f[:27236])
df = pd.DataFrame({'Time': x, 'Data': y})
#----Removes the outliers in a given DataFrame and plots a graph
newdf = df.copy()
newdf = df[~df.groupby('Data').transform(lambda x: abs(x-x.mean()) > 1.96*x.std()).values]
#newdf.plot('Time', 'Data')
#---Original DataFrame
x = (q[0].time[:47374])
y = (q[0].data.f[:47374])
df = pd.DataFrame({'Time': x, 'Data': y})
#----Removes the outliers in a given DataFrame and plots a graph
newdf = df.copy()
newdf2 = df[~df.groupby('Data').transform(lambda x: abs(x-x.mean()) > 1.96*x.std()).values]
#newdf2.plot('Time', 'Data')
#---Original DataFrame
x = (w[0].time[:25504])
y = (w[0].data.f[:25504])
df = pd.DataFrame({'Time': x, 'Data': y})
#----Removes the outliers in a given DataFrame and plots a graph
newdf = df.copy()
newdf3 = df[~df.groupby('Data').transform(lambda x: abs(x-x.mean()) > 1.96*x.std()).values]
#newdf3.plot('Time', 'Data')
#---Original DataFrame
x = (e[0].time[:47172])
y = (e[0].data.f[:47172])
df = pd.DataFrame({'Time': x, 'Data': y})
#----Removes the outliers in a given DataFrame and plots a graph
newdf = df.copy()
newdf4 = df[~df.groupby('Data').transform(lambda x: abs(x-x.mean()) > 1.96*x.std()).values]
#newdf4.plot('Time', 'Data')
#---Original DataFrame
x = (r[0].time[:21317])
y = (r[0].data.f[:21317])
df = pd.DataFrame({'Time': x, 'Data': y})
#----Removes the outliers in a given DataFrame and plots a graph
newdf = df.copy()
newdf5 = df[~df.groupby('Data').transform(lambda x: abs(x-x.mean()) > 1.96*x.std()).values]
#newdf5.plot('Time', 'Data')
#---Original DataFrame
x = (t[0].time[:47211])
y = (t[0].data.f[:47211])
df = pd.DataFrame({'Time': x, 'Data': y})
#----Removes the outliers in a given DataFrame and plots a graph
newdf = df.copy()
newdf6 = df[~df.groupby('Data').transform(lambda x: abs(x-x.mean()) > 1.96*x.std()).values]
#newdf6.plot('Time', 'Data')
如果我刪除評論newdf.plot()
我就能單獨繪製所有圖形,但我想他們都在一個圖。
是的,我已經閱讀了http://matplotlib.org/examples/pylab_examples/subplots_demo.html 但該鏈接沒有任何示例與一個圖表中的多個圖表。
我也讀過這個:http://pandas-docs.github.io/pandas-docs-travis/visualization.html它有一些非常好的信息,但在一個圖中有多個圖的例子使用相同的數據框。我有6個獨立的數據框。 我想到了一個解決方案,我的問題是將所有的數據框寫入同一個Excel文件,然後從Excel中繪製它們,但這似乎過分,我不需要將這些數據保存到Excel文件中。
我的問題是這樣的: 如何在同一個圖中繪製多個熊貓數據框。下面斯科特的意見後
什麼圖形應更或類似
這種工作。它把我所有的情節都放到一張圖中,但它混雜了我所有的數據。我會發佈一個讓我的數據看起來像什麼的jpg,以及我的原始問題應該是什麼樣子。 –
所有的數據都是一樣的規模嗎?也許使用多個圖或至少多個y軸是有意義的。 –
那麼在第二個jpg中,它應該看起來像數據共享x/y軸。所以這就是我想要的,我不需要像這裏的示例那樣分開圖[link](http://matplotlib.org/examples/pylab_examples/subplots_demo.html),其中三個不同的圖共享兩個x/y軸。並且多個圖對我來說不起作用,因爲所有這些數據都在相同的參數下,我想將它們放在一起。 –