histogram

Python: Histogram with area normalized to something other than 1

怎甘沉沦 提交于 2019-11-30 15:09:56
问题 Is there a way to tell matplotlib to "normalize" a histogram such that its area equals a specified value (other than 1)? The option "normed = 0" in n, bins, patches = plt.hist(x, 50, normed=0, histtype='stepfilled') just brings it back to a frequency distribution. 回答1: Just calculate it and normalize it to any value you'd like, then use bar to plot the histogram. On a side note, this will normalize things such that the area of all the bars is normed_value . The raw sum will not be normed

How to construct unequal width histograms with Matlab?

落花浮王杯 提交于 2019-11-30 14:05:12
I would like to construct a histogram with unequal bins (intervals)..Matlab construct only histograms with equal bins as if it's a diagram..!!! Please help me...thanks a lot!! Here's an example: x = randn(100,1)*3; %# some random data e = [-10 -5 -3 -1 1 2 3 20]; %# edges of intervals: e(i) <= x < end(i+1) c = histc(x,e); %# get count in each interval bar(e, c, 'histc') %# bar plot set(gca, 'xlim',[e(1) e(end)]) 2 solutions: Specify bin centers with the 2nd argument to hist . Specify bin Edges with with the 2nd argument to histc . This function takes some further processing since it does not

How do I highlight an observation's bin in a histogram in R

▼魔方 西西 提交于 2019-11-30 14:01:34
I want to create a histogram from a number of observations (i.e. d <- c(1,2.1,3.4,4.5) ) and then highlight the bin that a particular observation falls in, such that I have an output that looks like this: how do I do this in R? Expanding on dangerstat's answer, here is a little function that will automatically find which bin contains the value that you want to highlight: highlight <- function(x, value, col.value, col=NA, ...){ hst <- hist(x, ...) idx <- findInterval(value, hst$breaks) cols <- rep(col, length(hst$counts)) cols[idx] <- col.value hist(x, col=cols, ...) } Now x <- rnorm(100)

ggplot2 histogram with density curve that sums to 1 [closed]

让人想犯罪 __ 提交于 2019-11-30 13:22:52
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . Plotting a histogram with a density curve that sums to 1 for non-standardized data is ridiculously difficult. There are many questions already about this, but none of their solutions work for my data. There needs to be a simple solution that just works. I can't find an answer with a simple solution

Howto bin series of float values into histogram in Python?

我们两清 提交于 2019-11-30 13:20:03
问题 I have set of value in float (always less than 0). Which I want to bin into histogram, i,e. each bar in histogram contain range of value [0,0.150) The data I have looks like this: 0.000 0.005 0.124 0.000 0.004 0.000 0.111 0.112 Whith my code below I expect to get result that looks like [0, 0.005) 5 [0.005, 0.011) 0 ...etc.. I tried to do do such binning with this code of mine. But it doesn't seem to work. What's the right way to do it? #! /usr/bin/env python import fileinput, math log2 = math

Stacked histogram from already summarized counts using ggplot2

喜欢而已 提交于 2019-11-30 13:02:33
I would like some help coloring a ggplot2 histogram generated from already-summarized count data. The data are something like counts of # males and # females living in a number of different areas. It's easy enough to plot the histogram for the total counts (i.e. males + females): set.seed(1) N=100; X=data.frame(C1=rnbinom(N,15,0.1), C2=rnbinom(N,15,0.1),C=rep(0,N)); X$C=X$C1+X$C2; ggplot(X,aes(x=C)) + geom_histogram() However, I'd like to color each bar according to the relative contribution from C1 and C2, so that I get the same histogram (i.e. overall bar heights) as in the above example,

Histogram equalization not working on color image - OpenCV

浪子不回头ぞ 提交于 2019-11-30 10:22:40
问题 I am trying to perform a histogram equalization using OpenCV using the following function Mat Histogram::Equalization(const Mat& inputImage) { if(inputImage.channels() >= 3) { vector<Mat> channels; split(inputImage,channels); Mat B,G,R; equalizeHist( channels[0], B ); equalizeHist( channels[1], G ); equalizeHist( channels[2], R ); vector<Mat> combined; combined.push_back(B); combined.push_back(G); combined.push_back(R); Mat result; merge(combined,result); return result; } return Mat(); } But

Plot timeseries of histograms in Python

寵の児 提交于 2019-11-30 09:30:17
I'm trying to plot a time-series of histograms in Python. There has been a similar question about this, but in R . So, basically, I need the same thing, but I'm really bad in R. There are usually 48 values per day in my dataset. Where - 9999 represents missing data. Here's the sample of the data. I started with reading in the data and constructing a pandas DataFrame . import pandas as pd df = pd.read_csv('sample.csv', parse_dates=True, index_col=0, na_values='-9999') print df <class 'pandas.core.frame.DataFrame'> DatetimeIndex: 336 entries, 2008-07-25 14:00:00 to 2008-08-01 13:30:00 Data

GNUPLOT - Two columns histogram with values on top of bars

不羁的心 提交于 2019-11-30 09:17:09
问题 yesteraday I made a similar question (this one). I could not display the value on top of bar in a gnuplot histogram. I lost many time because I couldn't find really good documentation about it, and I only can find similar issues on differents websites. I lost many time with that but fortunately someone give me the solution. Now I am having a similar issue with an histogram with two bars, in which I have to put on top of both bars its value. I am quite near, or that is what I think, but I can

Simple histogram generation of integer data in C#

回眸只為那壹抹淺笑 提交于 2019-11-30 09:16:24
As part of a test bench I'm building, I'm looking for a simple class to calculate a histogram of integer values (number of iterations taken for an algorithm to solve a problem). The answer should be called something like this: Histogram my_hist = new Histogram(); for( uint i = 0; i < NUMBER_OF_RESULTS; i++ ) { myHist.AddValue( some_result ); } for( uint j = 0; j < myHist.NumOfBins; j++ ) { Console.WriteLine( "{0} occurred {1} times", myHist.BinValues[j], myHist.BinCounts[j] ); } I was suprised a bit of googling didn't turn up a neat solution but maybe I didn't search for the right things. Is