Reputation: 65
I have a Dataframe which I'm using to create a bar plot.
This is the code that generated the plot.
from matplotlib import pyplot as plt
import pandas as pd
gendercrcard=pd.DataFrame({'Gender':['Female','Female','Male','Male'],'Hascrcard':['No','Yes','No','Yes'],'count':[1351,3192,1594,3863]})
gendercrcard.plot(kind='bar')
plt.title('Credit Card Status with Gender', size = 20)
plt.xticks(size = 15, rotation = 0)
plt.ylabel('Frequency', size = 15)
plt.show()
My xticks
currently correspond to their index in the df
. However, the index number do not provide context.
Is there a way to change them so that they say 'Male/Female' and 'Credit card/No credit card'?
I'd Also like to change the colour of the boxes (e.g. male = blue and female = pink).
Upvotes: 0
Views: 170
Reputation: 96
Since no code has been given to work with, here are the general solutions to your problem.
To manipulate/customize your xticks please refer to the Documentation
To change the color of your Barplots, the solution to that has already been answered in the following link.
Or consider reading the Documentation.
Upvotes: 1