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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Python padding doesn't work in Power BI Service

Hi all,

 

I am using python to built a boxplot graph. As you may know, padding in python is not that good so in order to improve my graph size I am using plt.tight_layout(). This works perfect in PBI Desktop but once I publish my report, the original padding comes back. 

 

This is my first work in power bi using python, Am I missing something?

 

Thanks,

 

Cesar

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Xiaoxin,

I found the solution, for boxplots instead of using plt.tight_layout() I needed to use plt.figure(figsize=(20,5)).

It is not a perfect option because there is still some non-optimized surrounding spaces, but at least it works with PBI services.

 

Regards,

 

Cesar

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

I'd like to suggest you to take a look at following blog about power bi and python script:

Python visualizations in Power BI Service

Spoiler
The Python scripts in your reports are executed by the Power BI service in an isolated sandbox that restricts the access of the scripts to the network and the other machine resources. This ensures that your datasets and the Power BI service are not vulnerable to attacks.

As document said, all python script execute in a sandbox and power bi will block the access of extra resources. It may block some functions work on power bi service side.

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi Xiaoxin,

I found the solution, for boxplots instead of using plt.tight_layout() I needed to use plt.figure(figsize=(20,5)).

It is not a perfect option because there is still some non-optimized surrounding spaces, but at least it works with PBI services.

 

Regards,

 

Cesar

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors