French_movie_genre_count = French_movies['Genre_count']
non_French_movies_genre_count = non_French_movies['Genre_count']
fig, ax = plt.subplots(1,2)
plt.figure(figsize=(20, 16))
sns.countplot(x = French_movie_genre_count, color = 'blue', ax = ax[0])
sns.countplot(x = non_French_movies_genre_count, color = 'green', ax=ax[1])
fig.show()
如何把这来个图放到一个表里啊?
把下面这两个分开的图 合并到一个图里面 最好能归一化 变成百分比
1,使用pandas中apply函数对列数据处理成百分比,2.使用plot()绘制图像。参考代码:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
French_movies=pd.read_csv('French_movies.csv')
non_French_movies = pd.read_csv('non_French_movies.csv')
French_movie_genre_count = French_movies['Genre_count'].apply(
lambda x: x/French_movies['Genre_count'].sum())
non_French_movies_genre_count = non_French_movies['Genre_count'].apply(
lambda x: x/non_French_movies['Genre_count'].sum())
df = pd.DataFrame({'french_movie_count': French_movie_genre_count, 'non_french_movie_count': non_French_movies_genre_count})
print(df)
df.plot(kind='bar',
figsize=(18, 6),
title='French_movies and non_French_movies',
rot=0)
plt.show()