在子图中绘制不同的数据框数据

时间:2020-04-05 12:51:27

标签: python-3.x pandas dataframe matplotlib data-visualization

我试图在两个子图中的两个数据框中绘制数据。我指的是this link

PS C:\Users\azure> docker run --platform=linux hello-world:linux
docker : C:\Program Files\Docker\docker.exe: Error response from daemon: failed to start 
service utility VM (createreadwrite): hcsshim::CreateComputeSystem 
2410bb8b9e431b1068750d0c79376b1fdc196eef97c0a48ec8571775349acde7_svm: The virtual machine 
could not be started because a required feature is not installed.
At line:1 char:1
+ docker run --platform=linux hello-world:linux
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Program File... not installed.:String) [], 
    RemoteException
    + FullyQualifiedErrorId : NativeCommandError

(extra info: {"SystemType":"container","Name":"2410bb8b9e431b1068750d0c79376b1fdc196eef97c0
a48ec8571775349acde7_svm","Layers":null,"HvPartition":true,"HvRuntime":{"ImagePath":"C:\\Pr
ogram Files\\Linux Containers","LinuxInitrdFile":"initrd.img","LinuxKernelFile":"kernel"},"
ContainerType":"linux","TerminateOnLastHandleClosed":true}).
See 'C:\Program Files\Docker\docker.exe run --help'. 

但是,出现以下错误

onRestoreInstanceState

有关如何解决此问题的任何建议将非常有帮助。 编辑:下面提供的答案适用于1行2列

我遇到2行2列的错误

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


df1 = pd.DataFrame(np.random.randn(10, 10))
df2 = pd.DataFrame(np.random.randn(10, 10))


plt.figure()
fig, axes = plt.subplots(nrows=1, ncols=2)

df1.plot(ax=axes[0, 0], style='o-')
axes[0, 0].set_xlabel('x')
axes[0, 0].set_ylabel('y')
axes[0, 0].set_title('ttl')

df2.plot(ax=axes[0, 1], style='o-')
axes[0, 1].set_xlabel('x')
axes[0, 1].set_ylabel('y')
axes[0, 1].set_title('ttl')

错误:

df1.plot(ax=axes[0, 0], style='o-')
IndexError: too many indices for array

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

轴是一维的,您必须这样做:

df1.plot(ax=axes[0], style='o-')
df2.plot(ax=axes[1], style='o-')

我建议阅读this,查看squeeze参数,您将了解这种情况。