Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matplotlib 单个窗口中的多个绘图_Matplotlib_Seaborn - Fatal编程技术网

Matplotlib 单个窗口中的多个绘图

Matplotlib 单个窗口中的多个绘图,matplotlib,seaborn,Matplotlib,Seaborn,我需要在一个窗口中绘制许多这样的行(对于a0..a128)。我已经在FaceGrid,PairGrid中搜索过了,但是没有找到。只有regplot具有类似的参数ax,但它不绘制直方图。我的数据是128个带标签列[0,1]的实值要素。我需要将Python代码中的图形显示为Linux上的一个单独应用程序 此外,是否有一种方法来缩放此直方图,以显示Y上的相对值,从而使右曲线不倾斜 g = sns.FacetGrid(df, col="Result") g.map(plt.hist, "a0", bi

我需要在一个窗口中绘制许多这样的行(对于a0..a128)。我已经在
FaceGrid
PairGrid
中搜索过了,但是没有找到。只有
regplot
具有类似的参数
ax
,但它不绘制直方图。我的数据是128个带标签列[0,1]的实值要素。我需要将Python代码中的图形显示为Linux上的一个单独应用程序

此外,是否有一种方法来缩放此直方图,以显示Y上的相对值,从而使右曲线不倾斜

g = sns.FacetGrid(df, col="Result")
g.map(plt.hist, "a0", bins=20)

plt.show()

这只是一个使用matplotlib的简单示例。代码未优化(丑陋,但简单的打印索引):

输出:


您的环境和数据看起来有点不清楚。使用matplotlib的子绘图很容易。FacetGrid可能会工作,这取决于您的数据帧。关于您的规范化:matplotlib.hist采用
density=True
,您也应该能够将此发布到seaborn。更新了答案。你有一个例子如何使用一些FaceGrid的子地块?就我所知,FaceGrid应该替换子地块(做整个子地块的事情)。编辑:啊,你想要小平面网格。。。哎哟查看文档。我认为FaceGrid是一个图形对象(不是axis对象!),你会遇到问题。我只需要最短的解决方案,我认为可以用seaborn完成。看起来它将是numpy.histogram(),然后放在任何库中的手动绘图上,到目前为止。不需要使用np.hist。只需用plt.subplot或任何其他函数构建一个网格,并用plt.hist填充这些网格。FacetGrid也可以这样做,如果您的数据帧设置正确的话。但是关于你的任务没有太多的信息。
import numpy as np
import matplotlib.pyplot as plt

N = 5

data = np.random.normal(size=(N*N, 1000))

f, axarr = plt.subplots(N, N)  # maybe you want sharex=True, sharey=True

pi = [0,0]
for i in range(data.shape[0]):
    if pi[1] == N:
        pi[0] += 1  # next row
        pi[1] = 0   # first column again

    axarr[pi[0], pi[1]].hist(data[i], normed=True)  # i was wrong with density;
                                                    # normed=True should be used

    pi[1] += 1

plt.show()