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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jaysam
Regular Visitor

Python visual long x-axis labels gets cut off on Power BI Desktop

Hi all, 

 

I am trying to have a python visual displayed on Power BI Desktop. I implemented my plot on Jupyter Notebooks and it appears as expected. However, when the plot gets displayed on Power BI Desktop, parts of the x-axis labels gets cut off. My plot has long x-axis labels and they need to be displayed on the x-axis (not in a legend). These labels display best when at a 90 degrees rotation.

 

Things I have tried so far:

- Using a smaller figure size for plot in python code

- Trying other x-axis label angle rotation (30, 45, 60 degrees)

- Publishing Power BI desktop report to Power BI My Workspace

 

I have created a sample stripplot to show the issue I am experiencing:

Plot on Jupyter Notebook

jaysam_0-1660006230406.png

 

Plot on Power BI Desktop

jaysam_1-1660006251359.png

 

Any advice on how to fix this issue will be greatly appreciated.

 

1 ACCEPTED SOLUTION

this one seems to work "better" 

fig, ax = plt.subplots(1,1,figsize=(16,16))
sns.stripplot(data=dataset, x="x label", y="Concentration", ax=ax)
fig.autofmt_xdate(rotation=90)
plt.show()

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

please show the code and provide the sample data for the dataframe/dataset.

 

# code as applied in Power BI

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

plot_table = dataset

ax = sns.stripplot(data=plot_table, x="x label", y="Concentration")

ax.tick_params(axis='x', rotation=90)

plt.show()

 

 

I do not see a place to attach the excel table, so please see it included as a google sheet
https://docs.google.com/spreadsheets/d/1eRbP0wyM42_EDEw5I1VyKkqRDMnhd358/edit?usp=sharing&ouid=10187...

 

Thank you for taking the time to look into this

this one seems to work "better" 

fig, ax = plt.subplots(1,1,figsize=(16,16))
sns.stripplot(data=dataset, x="x label", y="Concentration", ax=ax)
fig.autofmt_xdate(rotation=90)
plt.show()

That solves the issue.

 

THANK YOU!!!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.