'Building a histogram

How can a distribution histogram similar to this one be constructed based on the data from the table? enter image description here

enter image description here

Code python:

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_excel('Data.xlsx')
print(df)
df.plot.hist(df)
plt.show()


Solution 1:[1]

It isn't clear exactly what the x and y axes of your desired plot are. Hopefully this will get you started. Sometimes trying to comeup with a MRE will help you solve your own problem.

import random
import pandas as pd

import matplotlib.pyplot as plt

#######################################
# generate some random data for a MWE #
#######################################
random.seed(22)
data = [random.randint(0, 100) for _ in range(0, 10)]
data = pd.Series(sorted(data))

freqs = [random.uniform(0, 1) for _ in range(0, 10)]
freqs = sorted(freqs)
freqs = pd.Series(freqs)


df = pd.DataFrame()
df['data'] = data
df['frequencies'] = freqs

###############################################
# Desired bar plot using pandas built in plot #
###############################################
df.plot(x='data', y='frequencies', kind='bar')

plt.show()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1