Forum Discussion

barakb32's avatar
barakb32
Advocate I
7 years ago
Solved

Python padding

Hi,

 

I used the Python visual to embed a scatter in my report.

I would like the scatter to fill the screen. I have 2 issues with that:

 

1. The python visual comes with a lot of padding. I have huge white space between the border of the visual and the axis of the scatter

2. The scatter comes out square. I don't know how to make its width larger than its height, even if the visual wrapping it is more wide than tall

 

Can this be solved in for Python visual or for R visual?

 

Thanks,

Barak

  • OK,

     

    Solved it with the size and aspect parameters.

     

    Barak

6 Replies

  • v-yuta-msft's avatar
    v-yuta-msft
    Community Support

    barakb32 ,

     

    The padding size should be decided by the python code you are using. Could you share some part of the python code for further analysis?

     

    Community Support Team _ Jimmy Tao

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • barakb32's avatar
      barakb32
      Advocate I

      This is the code as it appears in Power BI:

       

       

      import matplotlib.pyplot as plt
      import pandas as pd 
      import seaborn as sns
      sns.set_palette("pastel")
      #print (sns.get_dataset_names())
      df = pd.DataFrame(dict(x=dataset['Probability01'], y=dataset['Impact110']))
      #plt.scatter(x=dataset['Probability01'],y=dataset['Impact110'],s=dataset['Booking']/10000)
      lm=sns.lmplot(x='Probability01',y='Impact110',data=dataset,hue='Proj_Type',scatter_kws={'s': dataset['Booking']/10000})
      #axes=lm.axes
      #axes[0,0].set_ylim(-1,)
      #axes[0,1].set_xlim(0,)
      plt.xlim(-0.1,1.1)
      plt.ylim(-1,11)
      for i, txt in enumerate(dataset["Project Name"]):
      plt.annotate(txt, (df.x.iat[i],df.y.iat[i]),fontsize=15)
      plt.show()

       

       

      and this is how it appears in spyder:

       

      # Prolog - Auto Generated #
      import os, matplotlib.pyplot, uuid, pandas
      os.chdir(u'C:/Users/barakb/PythonEditorWrapper_2dac1e75-9317-429d-ac0d-8f5d9b7f0e89')
      dataset = pandas.read_csv('input_df_55fe400c-1be7-4c16-b559-82ca736d13b9.csv')
      matplotlib.pyplot.figure(figsize=(10,10))
      matplotlib.pyplot.show = lambda args=None,kw=None: matplotlib.pyplot.savefig(str(uuid.uuid1()))
      # Original Script. Please update your script content here and once completed copy below section back to the original editing window #
      import matplotlib.pyplot as plt
      import pandas as pd 
      import seaborn as sns
      sns.set_palette("pastel")
      #print (sns.get_dataset_names())
      df = pd.DataFrame(dict(x=dataset['Probability01'], y=dataset['Impact110']))
      #plt.scatter(x=dataset['Probability01'],y=dataset['Impact110'],s=dataset['Booking']/10000)
      lm=sns.lmplot(x='Probability01',y='Impact110',data=dataset,hue='Type',scatter_kws={'s': dataset['Booking']/10000})
      #axes=lm.axes
      #axes[0,0].set_ylim(-1,)
      #axes[0,1].set_xlim(0,)
      plt.xlim(-0.1,1.1)
      plt.ylim(-1,11)
      for i, txt in enumerate(dataset["Project Name"]):
      plt.annotate(txt, (df.x.iat[i],df.y.iat[i]),fontsize=15)
      plt.show()
       
      
      # Epilog - Auto Generated #
      os.chdir(u'C:/Users/barakb/PythonEditorWrapper_2dac1e75-9317-429d-ac0d-8f5d9b7f0e89')

       

      BTW1: I don't think that's a Python padding, since I changed the visual background to transparent and put a rectangle behind it.

      While the plot area hides the rectangle, the padding/whitespace doesn't hide it.

       

      BTW2: There is not much padding when the visual is small. The padding comes intoplace when I enlarge the visual to fill the screen.

       

      Barak 

      • barakb32's avatar
        barakb32
        Advocate I

        OK,

         

        Solved it with the size and aspect parameters.

         

        Barak