mk8efz
mk8efz

Reputation: 1424

Plotting frequency distribution/histogram with frequency table

I'm familiar with the matplotlib histogram reference:

http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.hist

However, I don't actually have the original series/data to pass into the plot. I have only the summary statistics in a DataFrame. Example:

df

lower  upper  occurrences  frequency
0.0    0.5    17           .111
0.5    0.1    65           .426
0.1    1.5    147          .963
1.5    2.0    210          1.376
.
.
.

Upvotes: 2

Views: 5642

Answers (1)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339280

You don't want to calculate a histogram here, because you already have the histogrammed data. Therefore you may simply plot a bar chart.

fig, ax = plt.subplots()
ax.bar(df.lower, df.occurences, width=df.upper-df.lower, ec="k", align="edge")

Upvotes: 3

Related Questions