单个 window 中的多个地块
Mutiple plots in a single window
我需要在单个 window 中绘制许多这样的行(对于 a0 .. a128)。我在 FacetGrid
、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 的简单示例。代码未优化(丑陋,但简单的绘图索引):
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()
输出:
我需要在单个 window 中绘制许多这样的行(对于 a0 .. a128)。我在 FacetGrid
、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 的简单示例。代码未优化(丑陋,但简单的绘图索引):
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()
输出: