histogram

3D histogram with gnuplot or octave

做~自己de王妃 提交于 2019-11-28 08:43:44
I would like to draw a 3D histogram (with gnuplot or octave) in order to represent my data. lets say that I have a data file in the following form: 2 3 4 8 4 10 5 6 7 I'd like to draw nine colored bars (the size of the matrix), in the set [1,3]x[1,3], such that the bar's color is proportional to the bar's height. How can I do this? Amro Below is a function I implemented that acts as a bar3 replacement (partially). In my version, the bars are rendered by creating a patch graphics object : we build a matrix of vertex coordinates and a list of faces connecting those vertices . The idea is to

C++ counting instances / histogram using std::map

微笑、不失礼 提交于 2019-11-28 08:35:20
问题 I have seen sample code similar to the following: std::string s = "Hello World!"; std::map<char, std::size_t> h; for (std::string::const_iterator i=s.cbegin(); i!=s.cend(); ++i) { ++h[*i]; } assert(h['l'] == 3); This seems to rely on the value type being zeroed on the first occurence of each letter. Is this guaranteed even when using something like a std::size_t which has no default constructor resetting it to zero? 回答1: Indeed that's how map works: The [] -operator is mutating and will

GNUPLOT: 2d histogram from set of points

爱⌒轻易说出口 提交于 2019-11-28 08:32:39
问题 I have a pairs of the points with their weights: #x y w 0.111342 0.478917 0.232487 0.398107 1.79559 0.221714 0.200731 2.58651 0.0776068 0.0967412 1.49904 0.0645355 6.17638 8.63101 0.715604 0.306128 3.10917 0.0984595 0.340707 3.19344 0.10669 7.18627 8.59859 0.835751 8.56 9.63894 0.888065 5.14272 6.86074 0.749587 0.747202 3.812 0.196013 8.71891 10.1355 0.860232 0.346714 1.45895 0.237647 5.21932 8.84491 0.590094 9.42138 12.2082 0.771725 0.215627 2.42317 0.0889856 How to plot nice 2d histogram

plot histogram of datetime.time python / matplotlib

↘锁芯ラ 提交于 2019-11-28 08:30:41
I am trying to plot a histogram of datetime.time values. Where these values are discretized into five minute slices. The data looks like this, in a list: ['17:15:00', '18:20:00', '17:15:00', '13:10:00', '17:45:00', '18:20:00'] I would like to plot a histogram, or some form of distribution graph so that the number of occurrences of each time can be examined easily. NB. Given each time is discretised then. The maximum number of bins in a histogram would be 288 = (60 / 5 * 24) I have looked at matplotlib.pyplot.hist. But is requires some sort of continuous scalar I did what David Zwicker said and

How to plot histogram/ frequency-count of a vector with ggplot?

浪子不回头ぞ 提交于 2019-11-28 07:48:18
问题 I want to plot with ggplot the frequency of values from a numeric vector. With plot() is quite straight forward but I can't get the same result with ggplot . library(ggplot2) dice_results <- c(1,3,2,4,5,6,5,3,2,1,6,2,6,5,6,4) hist(dice_results) ggplot(dice_results) + geom_bar() # Error: ggplot2 doesn't know how to deal with data of class numeric Should I create a dataframe for ggplot() to plot my vector? 回答1: Please look at the help page ?geom_histogram . From the first example you may find

How to separate the two leftmost bins of a histogram in R

我怕爱的太早我们不能终老 提交于 2019-11-28 07:37:57
问题 Suppose I need to plot a dataset like below: set.seed(1) dataset <- sample(1:7, 1000, replace=T) hist(dataset) As you can see in the plot below, the two leftmost bins do not have any space between them unlike the rest of the bins. I tried changing xlim, but it didn't work. Basically I would like to have each number (1 to 7) represented as a bin, and additionally, I would like any two adjacent bins to have space beween them...Thanks! 回答1: The best way is to set the breaks argument manually.

How to use the function curve in [R] to graph a normal curve?

柔情痞子 提交于 2019-11-28 07:25:20
问题 I'm trying to make a histogram in [R], and the normal curve that describes the histogram as follows: w<-rnorm(1000) hist(w,col="red",freq=F,xlim=c(-5,5)) curve(dnorm(w),-5,5,add=T,col="blue") But when I try to plot the normal curve by curve function shows me the following error: Error en curve(dnorm(w), -5, 5, add = T, col = "blue") : 'expr' must be a function, or a call or an expression containing 'x' What am I doing wrong? 回答1: You just need to drop the "w" argument to dnorm in curve : w<

Making a histogram of string values in python

自古美人都是妖i 提交于 2019-11-28 07:21:58
问题 OK so I have six possible values for data to be which are '32', '22', '12', '31', '21' and '11'. I have these stored as strings. Is it possible for python to sort through the data and just make six bins and show how many of each I have? Or do the inputs to a histogram HAVE to be numerical? 回答1: data = ['32', '22', '12', '32', '22', '12', '31', '21', '11'] dict((x, data.count(x)) for x in data) Result {'11': 1, '12': 2, '21': 1, '22': 2, '31': 1, '32': 2} 回答2: Did you consider using

Use hist() function in R to get percentages as opposed to raw frequencies

霸气de小男生 提交于 2019-11-28 06:20:34
How can one plot the percentages as opposed to raw frequencies using the hist() function in R? Brian Simply using the freq=FALSE argument does not give a histogram with percentages, it normalizes the histogram so the total area equals 1. To get a histogram of percentages of some data set, say x, do: h = hist(x) # or hist(x,plot=FALSE) to avoid the plot of the histogram h$density = h$counts/sum(h$counts)*100 plot(h,freq=FALSE) Basically what you are doing is creating a histogram object, changing the density property to be percentages, and then re-plotting. If you want explicitly to list every

Plotting a histogram from pre-counted data in Matplotlib

馋奶兔 提交于 2019-11-28 06:17:38
I'd like to use Matplotlib to plot a histogram over data that's been pre-counted. For example, say I have the raw data data = [1, 2, 2, 3, 4, 5, 5, 5, 5, 6, 10] Given this data, I can use pylab.hist(data, bins=[...]) to plot a histogram. In my case, the data has been pre-counted and is represented as a dictionary: counted_data = {1: 1, 2: 2, 3: 1, 4: 1, 5: 4, 6: 1, 10: 1} Ideally, I'd like to pass this pre-counted data to a histogram function that lets me control the bin widths, plot range, etc, as if I had passed it the raw data. As a workaround, I'm expanding my counts into the raw data: