Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
kilala
Resolver I
Resolver I

Python Visualisation - Horizontal Bar Chart

Hi all, I'm a beginner in both python and power bi. I am trying to do horizontal bar chart in power bi but using python script. In my visualisation, sales will act as x-axis and subcategory will act as y-axis. However, the graph i made did not show the value for the sales(it looks weird). It did not start from 0 and the length of each data is not displayed.

 

kilala_0-1615911873570.png

This is my coding:

import matplotlib.pyplot as plt
import pandas as pd

data = dataset.Sales
df = pd.DataFrame(data,columns=[dataset.Sales], index =[dataset.Sub_Category])

df.plot.barh()
plt.title("Sales by Subcategory")
plt.ylabel("Sub_Category")
plt.xlabel("Sales")
plt.show()

I tried to search online but there are no tutorial that specific for python in power bi, so I'm confused. Hope the expert can helps me:)

 

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @kilala ,

Although I am not an expert in python, I think these documents and video below may be helpful to you about creating python visuals in power bi desktop:

  1. Create Power BI visuals by using Python 
  2. Using Python Visuals in Power BI 
  3. Power BI - Introduction to Python Visuals 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PhilipTreacy
Super User
Super User

Hi @kilala 

Please supply your dataset as a file
Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors