I am trying to create subplots: first Pie plot (got it), second bar plot (didn't succeed):
These are the columns:
My Code:
top_series = all_data.head(50).groupby('Top Rated ')['Top Rated '].count()
top_values = top_series.values.tolist()
top_index = ['Top Rated', 'Not Top Rated']
top_colors = ['#27AE60', '#E74C3C']
all_data['Rating_Cat'] = all_data['Rating'].apply(lambda x : 'High' if (x > 10000000 ) else 'Low')
rating_series = all_data.head(50).groupby('Rating_Cat')['Rating_Cat'].count()
rating_values = rating_series.values.tolist()
rating_index = ['High' , 'Low']
rating_colors = ['#F1C40F', '#27AE60']
fig, axs = plt.subplots(1,2, figsize=(16,5))
axs[0].pie(top_values, labels=top_index, autopct='%1.1f%%', shadow=True, startangle=90,
explode=(0.05, 0.05), radius=1.2, colors=top_colors, textprops={'fontsize':12})
all_data['Rating_Cat'].value_counts().plot(kind = 'bar', ax=axs[1])
fig.suptitle('Does "Rating" really affect on Top Sellers ?' , fontsize=17)
My question:
How to create the second plot that will get output like:
axis X = 1 , 2 , 3 , 4 .... 50 + Top reated / NO (according to the current col)
axis y = the rating from 0 to 7603388.0
I have really tried lots of things, but I am kind of lost here... please help !!
In first plot you are taking first 50 rows of the dataset and plot shares of each value in
Top Rated
column.If I understand what you are trying to do in second plot (You want to have each of the
Rating
from first 100 values plotted from first to last with color based on the Top rated):If you want to add legend to the plot, you have to do it manually
Edit: My whole code