Questions tagged [histogram]

In statistics, a histogram is a graphical representation, showing a visual impression of the distribution of data.

In statistics, a histogram is a graphical representation, showing a visual impression of the distribution of data. It is an estimate of the probability distribution of a continuous variable and was first introduced by Karl Pearson. A histogram consists of tabular frequencies, shown as adjacent rectangles, erected over discrete intervals (bins), with an area equal to the of the observations in the interval. The height of a rectangle is also equal to the frequency density of the interval, i.e., the frequency divided by the width of the interval. The total area of the histogram is equal to the number of data. A histogram may also be normalized displaying relative frequencies. It then shows the proportion of cases that fall into each of several categories, with the total area equaling 1. The categories are usually specified as consecutive, non-overlapping intervals of a variable. The categories (intervals) must be adjacent, and often are chosen to be of the same size.

Histograms are used to plot density of data, and often for density estimation: estimating the probability density function of the underlying variable. The total area of a histogram used for probability density is always normalized to 1. If the length of the intervals on the x-axis are all 1, then a histogram is identical to a relative frequency plot.

In scientific software for statistical computing and graphics, The function hist generates a histogram. It can also optionally scale it so that its total area is 1. This puts it in the right scale if one want to overlay a probability density curve.

More about it here : histogram wiki

6663 questions
8
votes
2 answers

histogram without vertical lines

When I create a histogram, it looks a lot like this: set.seed(1) x <- 1:100 y <- x + rnorm(50) y=round(y) hist(y) Is there a way to make a histogram look a bit like this? I can only get a histogram with bins, which I don't need for my plot. I…
Sir Ksilem
  • 1,195
  • 2
  • 12
  • 27
8
votes
2 answers

How to re-scale the counts in a matplotlib histogram

I have a matplotlib histogram that works fine. hist_bin_width = 4 on_hist = plt.hist(my_data,bins=range(-100, 200,hist_bin_width),alpha=.3,color='#6e9bd1',label='on') All I want to do is to rescale by a factor of, say, 2. I don't want to change the…
user1551817
  • 6,693
  • 22
  • 72
  • 109
8
votes
2 answers

Weighted histogram plotly

I'm looking to migrate from matplotlib to plotly, but it seems that plotly does not have good integration with pandas. For example, I'm trying to make a weighted histogram specifying the number of bins: sns.distplot(df.X, bins=25,…
Luis Ramon Ramirez Rodriguez
  • 9,591
  • 27
  • 102
  • 181
8
votes
2 answers

Show the percentage instead of count in histogram using ggplot2 | R

I'm using a histogram to plot my 3 groups data. But as histogram do, it counts how much each group have those values (in x-axis) and what I want is to the percentage of how much (in %) this value appears/occurs. Here is my generated figure, I use…
LamaMo
  • 576
  • 2
  • 8
  • 19
8
votes
2 answers

How to plot normalized histogram with pdf properly using matplotlib?

I try to plot normalized histogram using example from numpy.random.normal documentation. For this purpose I generate normally distributed random sample. mu_true = 0 sigma_true = 0.1 s = np.random.normal(mu_true, sigma_true, 2000) Then I fitt…
Einar A
  • 141
  • 1
  • 1
  • 9
8
votes
3 answers

NumPy - calculate histogram intersection

The following data, represent 2 given histograms split into 13 bins: key 0 1-9 10-18 19-27 28-36 37-45 46-54 55-63 64-72 73-81 82-90 91-99 100 A 1.274580708 2.466224824 5.045757621 7.413716262 8.958855646 10.41325305…
Shlomi Schwartz
  • 8,693
  • 29
  • 109
  • 186
8
votes
2 answers

Plotting means on histograms created with facet_wrap

I'm making a several histograms using ggplot2 and facet_wrap and would like to plot the mean value on each panel. Below, I create a dummy data frame, find the mean of each facet, and then create the plots adding the mean using geom_point. # Load…
Dan
  • 11,370
  • 4
  • 43
  • 68
8
votes
2 answers

Understanding hist() and break intervals in R

I've recently started using R and I don't think I'm understanding the hist() function well. I'm currently working with a numeric vector of length 296, and I'd like to divide it up into 10 equal intervals, and produce a frequency histogram to see…
Bobby
  • 81
  • 1
  • 1
  • 2
8
votes
1 answer

Grafana expression for prometheus histogram

Can anyone help me with visualising a prometheus histogram as both a chart and apdex please? Ignoring any secondary labelling (for now) I'd just like to be able to visualise them as a histogram on Grafana (stacked bar chart is fine) and it would be…
eggsy84
  • 1,059
  • 1
  • 14
  • 26
8
votes
2 answers

probability density histogram with Matplotlib doesnt make sense

I have just run a simple task of trying to plot the probability density histogram for a simulation I ran. However, when I plot it, the probability for each bin seems not to match the result of the frequency plot. with 50 bins i would expect each bin…
Moj
  • 85
  • 1
  • 7
8
votes
3 answers

Pandas TimeGrouper and Pivot?

This is what my dataframe looks like: Timestamp CAT 0 2016-12-02 23:35:28 200 1 2016-12-02 23:37:43 200 2 2016-12-02 23:40:49 300 3 2016-12-02 23:58:53 400 4 2016-12-02 23:59:02 300 ... This is what I'm trying to…
andraiamatrix
  • 346
  • 3
  • 12
8
votes
1 answer

How can i control bin intervals in ggplot2?

I cant correctly control if a bin is going from e.g. -10 to +10 or from 0 to 20 when I say binwidth = 20 i get the former but I have data that begins at 1 and I dont want the interval to go into the negatives. Here is an example of my…
voiDnyx
  • 975
  • 1
  • 11
  • 24
8
votes
2 answers

Hide histogram plot

So I want to plot a normal distribution, and I've seen one way to do this is by using this code: import numpy as np import matplotlib.pyplot as plt mu = 5 sigma = 1 s = np.random.normal(mu, sigma, 1000) count, bins, ignored = plt.hist(s, 100,…
KaraiKare
  • 155
  • 1
  • 2
  • 10
8
votes
1 answer

Seaborn's histrogram bin widths not extending to bin labels

This is a different question from my last question. I'm printing a histogram using facetgrid through the following code. import numpy as np import pandas as pd import seaborn as sns import matplotlib as mpl import matplotlib.pyplot as plt titanic =…
Moondra
  • 4,399
  • 9
  • 46
  • 104
8
votes
3 answers

how to use compareHist function opencv

img = cv2.imread('mandrill.png') histg = cv2.calcHist([img],[0],None,[256],[0,256]) if len (sys.argv) < 2: print >>sys.stderr, "Usage:", sys.argv[0], "..." sys.exit (1) for fn in sys.argv[1:]: im = cv2.imread (fn) histr =…
Dappa jack
  • 145
  • 1
  • 2
  • 12