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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Python visual is not accurate

The matplotlib plot that shows up in Power BI, is different from that one, that the same code generates in a jupyter notebook.

Please help.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you @Pragati11  and @amitchandak .

The issue was with the sequence of columns. Power BI sends the columns in the alphabetical order, and not in the order in which the columns get uploaded.

Thanks again for your prompt support.

View solution in original post

14 REPLIES 14
Anonymous
Not applicable

Thank you @Pragati11  and @amitchandak .

The issue was with the sequence of columns. Power BI sends the columns in the alphabetical order, and not in the order in which the columns get uploaded.

Thanks again for your prompt support.

Pragati11
Super User
Super User

Hi @Anonymous ,

 

Can you share some screenshots here please with the following:

  1. Screenshot of scripts used in Jupyter and Power BI
  2. Screenshots of graph that is generated in Jupyter and Power BI

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

@Anonymous , can share some sample images?

Anonymous
Not applicable


@amitchandak wrote:

@Anonymous, can share some sample images?


Thank you for the prompt response Amit.
 
This is the code:
import pandas as pd
import pickle
import matplotlib.pyplot as plt

enq_loaded_model = pickle.load(open('C:ENQUIRY.sav', 'rb'))
y = enq_loaded_model.predict(dataset)
plt.plot(y)
plt.show()
 
First one is from Power BI, and the second one from jupyter notebookCapture.PNGCapture1.PNG

Hi @Anonymous ,

 

I can see the difference clearly in the y-axis scaling.

In Jupyter your y-axis range is till 2200, thereore the graph shows a different pattern.

In Power BI your y-axis range is till 2950, therefore graph is different.

 

In your pythin script when you are generating plot in Power BI, you will have to define range for your y-axis. Try giving this range similar to that in Jupyter notebook. I am sure you will get the same graph.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Hi @Pragati11 ,

 

Thank you.

 

It didn't work. First one is from Power BI, and the seocnd one from jupyter notebook.

 

It didn't work.Capture.PNGCapture1.PNG

 

Code:

 

import pandas as pd
import pickle
import matplotlib.pyplot as plt

enq_loaded_model = pickle.load(open('C:/ENQUIRY.sav', 'rb'))
# predict the enquiry
y = enq_loaded_model.predict(dataset)
plt.ylim([500,2500])
plt.plot(y)
plt.show()

Hi @Anonymous ,

 

Can you make sure that under this visual in Power BI, the fields that you have used - they are set to Don't Summarise?

 

This could be the reason why you don't see anything in Power BI for the same python script.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Checked again, @Pragati11 . Each one of them is set to "Don't Summarize".

Hi @Anonymous ,

 

Is it possible to share your pbix file?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Hi @Pragati11 ,

Hope you can access the files from here.

Dropbox 

Hi @Anonymous ,

 

Yes I can access them. Let me check and get back to you on this. 🙂

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi @Anonymous ,

 

I get following error on your script:

Pragati11_0-1623072258926.png

 

Is it working at your end?

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Hi @Pragati11 ,

 

Must be something with the settings. It is working just fine. Please refer to the attached screenshot.

Capture.PNG

Hi @Anonymous ,

 

I am not sure. there doesn't seem to be a setting issue.

I tried a case at my end by using xlim and it seems to work just fine at my end.

See below my original chart:

Pragati11_0-1623072748040.png

 

Now I set a limit on my x-axis and I get the following:

Pragati11_1-1623072818858.png

The only different thing I have used in my code is ax = plt.gca() to get the current axis and then apply limit on the axis range.

 

Can you try adding that in your python script and check it?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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