subplot - 在指定数量的行和列中绘制子图的问题
问题描述
所以我试图使用行和列中的子图来绘制“freq_cols”数据集中的所有列。但是,这些图仅显示所有框中的最后一列,而不是数据集中的各个列。这是我到目前为止所拥有的。请指教。谢谢!
freq_cols = frequency[['LF','LF_PCT','LF_NU','VLF','VLF_PCT','HF','HF_PCT','HF_NU','HF_LF','TP']]
fig, axs = plt.subplots(ncols = 5, nrows = 2, figsize = (30, 7))
for col_name, col_name in enumerate(freq_cols.columns):
for i in range(2):
for j in range(5):
sns.distplot(freq_cols[col_name], color='green', kde=True, ax = axs[i, j])
解决方案
只是猜测问题。
你已经写了两次 col_name
for col_name, col_name in enumerate(freq_cols.columns):
可能是你想写
for col_num, col_name in enumerate(freq_cols.columns):
也许下面可能有用
freq_cols = frequency[['LF','LF_PCT','LF_NU','VLF','VLF_PCT','HF','HF_PCT','HF_NU','HF_LF','TP']]
fig, axs = plt.subplots(ncols = 5, nrows = 2, figsize = (30, 7))
for col_num, col_name in enumerate(freq_cols.columns):
for i in range(2):
for j in range(5):
sns.distplot(freq_cols[col_name], color='green', kde=True, ax = axs[i, j])
推荐阅读
- environment-variables - terraform 不加载在 fish 中设置的环境变量
- c++ - 没有模板类孪生的模板类
- ios - API调用后UICollectionViewCell图像重新加载问题
- c++ - 使用 -O3 编译时的不同评估
- tinymce-5 - Tinymce 5:执行预定义插件的自定义工具栏按钮
- adb - 除了“127.0.0.1”之外,还有什么方法可以为多个连接的设备分配不同的本地 IP?
- shell - 在 dockerfile 运行时在 pom.xml 中添加配置
- c++ - 如何在 OpenCV Cuda (GpuMat) 中访问像素
- java - 如何修复“com.spotify.error.client_authentication_failed”
- autodesk-forge - 是否有适用于 Autodesk SVF 格式的规范?