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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Python Histogram not displaying correct data

Hi there,

 

I have a small dataset with just 80 datapoints and I am trying to plot a histogram with a normal distrubution curve on top of it. When I run the following code in Jupyter notebook, I got a nice distribution of the values. (first photo)

 

However, when I run the same code in Power BI using the Python visual, I get a totally different histogram. I checked populating a table with the data I am using for the histogram which seems correct, so the data in Power BI is correct but for some reason the visual doesnt depict the same data.Does anyone know why this is happening?

 

Also, if I dont filter out the one negative value in the dataset, the histogram seems to be pretty close to the actual result but as soon as I filter the one record with the negative value, the histogram changes completely in values.From Jupyter NotebookFrom Jupyter NotebookWith the negative recordWith the negative recordwithout negative recordwithout negative record

 

Code:

import numpy as np
from scipy.stats import norm
import matplotlib.pyplot as plt
import pandas as pd
plt.hist(dataset.UCS_PoissonsRatio, bins = 33, density = False, edgecolor = "#FFFFFF")
mu, std = norm.fit(dataset.UCS_PoissonsRatio)
xmin, xmax = plt.xlim()
x = np.linspace(xmin, xmax, 100)
p = norm.pdf(x, mu, std)
plt.plot(x, p, 'k', linewidth=2)
plt.xlabel("Poisson Ratio")
plt.ylabel("Frequency")
plt.show()
1 REPLY 1
lbendlin
Super User
Super User

please provide the sample dataset.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.