In our previous post we have seen how we can create vertical bar graph using Plotly library in Python. Here in this post we will see how we can plot horizontal bar graph using Plotly library.
For a data analyst it important that they get hands on experience on all important libraries that will help them to visualize the data in better way.
Here’s the below code for plotting the horizontal bar graph using Plotly:
We have imported
import pandas as pd import plotly.express as px Data = pd.read_excel(r"C:\Users\WeirdGeek\Desktop\WG_Test.xlsx") Data.head()
The above is the sample data that we are going to use for plotting out horizontal bar graph.
Below is the code that will plot the horizontal bar chart in plotly.
fig = px.bar(Data, x='Marks', y="Name", orientation='h') fig.show()
The above code will plot the chart i.e marks on x axis and Name on y axis. the important parameter is orientation = “h” which will plot the chart in horizontal mode.
To get more detailed knowledge about types of Charts, you can check the official Plotly website. Also if you want to explore more codes/posts related to same topic on our website, then you can find it here.
If you have any questions or if you need any help please get in touch with me using the comment section below.