I am trying to plot a histogram to view the distribution of all my observations, but keep getting plots with just one bar (histogram) or one point (scatterplot).
Sample Data:
state | excise | property | total |
---|---|---|---|
AL | 712.85 | 657.63 | 3948.49 |
AK | 550.36 | 2325.58 | 3406.33 |
AZ | 335.01 | 1244.10 | 4416.46 |
AR | 593.36 | 830.98 | 4634.21 |
CA | 629.92 | 2099.53 | 8666.15 |
CO | 570.25 | 2065.55 | 6159.76 |
First, I tried to plot a histogram to view the distribution of my data’s ‘total’ variable using the following:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig, ax - plt.subplots()
ax.hist('total', data='salt_cpc')
plt.show()
This resulted in a graph showing one singular bar- not a distribution of the 50 relation observations. I have also tried altering the number of bins, etc. which has not been fruitful.
histogram
I also tried plotting a scatterplot with two of the other variables (‘excise’ and ‘property’) and that returned a scatterplot with one point in the center of the graph.
fig, ax - plt.subplots()
ax.scatter('excise', 'property', data='salt_cpc')
plt.show()
scatterplot
databymir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.