Forum Discussion

jaysam's avatar
jaysam
Regular Visitor
4 years ago
Solved

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

 

Plot on Power BI Desktop

 

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

 

  • 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()

4 Replies

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

    • jaysam's avatar
      jaysam
      Regular Visitor

       

      # 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=101871073811717941462&rtpof=true&sd=true

       

      Thank you for taking the time to look into this

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        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()