【发布时间】:2020-07-28 19:33:20
【问题描述】:
用 matplotlib 绘图我得到了这 4 个直方图模型:
使用 Seaborn,我得到了我需要的确切图表,但我无法复制它一次获得 4 个:
我想以图像 1 的格式获取 4 个 seaborn 图表(图像 2)(一次 4 个,我使用 seaborn 进行的计算)。
我的 seaborn 代码如下:
import os
import re
import time
import ipdb
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
path_file = os.path.join(BASE_DIR, 'camel_product_list.csv')
gapminder = pd.read_csv(path_file)
print(gapminder.head())
df = gapminder
sns.distplot(df['average_histogram_ssim'], hist=True, kde = False, label='All values')
df = gapminder[gapminder.color == 'green']
# sns.distplot(df['lifeExp'], hist = True, kde = True, label='Only Matches')
sns.distplot(df['average_histogram_ssim'], hist_kws={"histtype": "step",
"linewidth": 3,
"alpha": 1, "color": "b"} ,
kde = False, label='Only Matches')
# Plot formatting
plt.legend(prop={'size': 12})
plt.title('ratio_image SSIM')
plt.xlabel('Data Range')
plt.ylabel('Density')
plt.show()
数据框的列名是:
'ratio_text','ratio_image', 'ratio_hist', 'ratio_sub', 'color'
我使用颜色列作为过滤器。
如何获得 ratio_text'、'ratio_image'、'ratio_hist'、'ratio_sub'、 的 4 个 seaborn 图,并按所有颜色和绿色进行过滤?
【问题讨论】:
-
我不确定我是否了解您遇到的问题。这些颜色在哪里发挥作用?
标签: python matplotlib seaborn