Jun-28-2020, 03:54 PM
Hi,
I have started Python programming classes last month to become a data analyst.
I have been blocked for a while with the following issue: how do I rename/replace the labels on the X axis of my bar chart in Matplotlib?
Here the link to the data I have been using: Data for bar chart
Right now I get numbers as labels (1,5,3,0,4,2)for the x axis.
I would like to replace / rename them with text of the first column of my data (labels should be: Data Analysis, Machine Learning, Data Visualization, Big Data, Deep Learning, Data journalist).
Here my code:
Thanks in advance for your huge help.
Stan
I have started Python programming classes last month to become a data analyst.
I have been blocked for a while with the following issue: how do I rename/replace the labels on the X axis of my bar chart in Matplotlib?
Here the link to the data I have been using: Data for bar chart
Right now I get numbers as labels (1,5,3,0,4,2)for the x axis.
I would like to replace / rename them with text of the first column of my data (labels should be: Data Analysis, Machine Learning, Data Visualization, Big Data, Deep Learning, Data journalist).
Here my code:
df_interested = pd.read_csv('https://cocl.us/datascience_survey_data') interested = df_interested.sort_values(['Very interested'], ascending = False, axis = 0, inplace = True) df_interested.plot(kind = 'bar', figsize = (20,8), width = 0.8, color=['#5cb85c', '#5bc0de', '#d9534f']) plt.title('Pourcentage of respondents interest in Data Science Areas', size = 16) plt.legend(prop={"size":14}) sns.despine() sns.despine(top=True, right=True, left=True, bottom=False) plt.xlabel("X Label") plt.ylabel("Y Label") ax = plt.gca() ax.axes.xaxis.set_visible(False) ax.axes.yaxis.set_visible(False) plt.grid(True) plt.show()The bar chart gets displayed the way I want. I am just struggling with the X axis labeling...
Thanks in advance for your huge help.
Stan