histogram

Side by Side histograms in the Same Graph in R?

孤街醉人 提交于 2019-11-28 20:36:10
This should actually be really simple but I'm having a really hard time finding a solution to this problem. I have two very simple numeric vectors in R. I am simply trying to plot a histogram with them. However I would like them to be on the same graph. The tricky part is R overlaps these two histograms by default. I would like the bins to be simply side by side so I can get a better visual representation of the data. Basically this is what I want to do I am fairly new to R and statistical computing languages in general so I would appreciate it if you would answer my frustrating problem. The

How to plot a density map in python?

*爱你&永不变心* 提交于 2019-11-28 20:26:47
I have a .txt file containing the x,y values of regularly spaced points in a 2D map, the 3rd coordinate being the density at that point. 4.882812500000000E-004 4.882812500000000E-004 0.9072267 1.464843750000000E-003 4.882812500000000E-004 1.405174 2.441406250000000E-003 4.882812500000000E-004 24.32851 3.417968750000000E-003 4.882812500000000E-004 101.4136 4.394531250000000E-003 4.882812500000000E-004 199.1388 5.371093750000000E-003 4.882812500000000E-004 1278.898 6.347656250000000E-003 4.882812500000000E-004 1636.955 7.324218750000000E-003 4.882812500000000E-004 1504.590 8.300781250000000E-003

Searching for a fast/efficient histogram algorithm (with pre-specified bins)

纵饮孤独 提交于 2019-11-28 20:07:05
问题 I don't do much coding outside of Matlab, but I have a need to export my Matlab code to another language, most likely C. My Matlab code includes a histogram function, histc(), that places my input data (which is double-precision, not integer) into a specified array of bins, to form a histogram. I'm sure I can piece together a couple nested loops to generate a histogram function, but I need this function to be fast and memory-light, as it will be accessed repeatedly and often. To avoid re

How do I generate points that match a histogram?

蓝咒 提交于 2019-11-28 19:43:17
I am working on a simulation system. I will soon have experimental data (histograms) for the real-world distribution of values for several simulation inputs. When the simulation runs, I would like to be able to produce random values that match the measured distribution. I'd prefer to do this without storing the original histograms. What are some good ways of Mapping a histogram to a set of parameters representing the distribution? Generating values that based on those parameters at runtime? EDIT: The input data are event durations for several different types of events. I expect that different

Numpy histogram of large arrays

感情迁移 提交于 2019-11-28 19:36:18
I have a bunch of csv datasets, about 10Gb in size each. I'd like to generate histograms from their columns. But it seems like the only way to do this in numpy is to first load the entire column into a numpy array and then call numpy.histogram on that array. This consumes an unnecessary amount of memory. Does numpy support online binning? I'm hoping for something that iterates over my csv line by line and bins values as it reads them. This way at most one line is in memory at any one time. Wouldn't be hard to roll my own, but wondering if someone already invented this wheel. mtrw As you said,

Gnuplot Histogram Cluster (Bar Chart) with One Line per Category

元气小坏坏 提交于 2019-11-28 19:32:27
Histogram Cluster / Bar Chart I'm trying to generate the following histogram cluster out of this data file with gnuplot , where each category is represented in a separate line per year in the data file: # datafile year category num_of_events 2011 "Category 1" 213 2011 "Category 2" 240 2011 "Category 3" 220 2012 "Category 1" 222 2012 "Category 2" 238 ... But I don't know how to do it with one line per category. I would be glad if anybody has got an idea how to do this with gnuplot. Stacked Histogram Cluster / Stacked Bar Chart Even better would be a stacked histogram cluster like the following,

Setting a relative frequency in a matplotlib histogram

丶灬走出姿态 提交于 2019-11-28 19:19:13
I have data as a list of floats and I want to plot it as a histogram. Hist() function does the job perfectly for plotting the absolute histogram. However, I cannot figure out how to represent it in a relative frequency format - I would like to have it as a fraction or ideally as a percentage on the y-axis. Here is the code: fig = plt.figure() ax = fig.add_subplot(111) n, bins, patches = ax.hist(mydata, bins=100, normed=1, cumulative=0) ax.set_xlabel('Bins', size=20) ax.set_ylabel('Frequency', size=20) ax.legend plt.show() I thought normed=1 argument would do it, but it gives fractions that are

Histogram in matplotlib, time on x-Axis

别说谁变了你拦得住时间么 提交于 2019-11-28 19:17:50
I am new to matplotlib (1.3.1-2) and I cannot find a decent place to start. I want to plot the distribution of points over time in a histogram with matplotlib. Basically I want to plot the cumulative sum of the occurrence of a date. date 2011-12-13 2011-12-13 2013-11-01 2013-11-01 2013-06-04 2013-06-04 2014-01-01 ... That would make 2011-12-13 -> 2 times 2013-11-01 -> 3 times 2013-06-04 -> 2 times 2014-01-01 -> once Since there will be many points over many years, I want to set the start date on my x-Axis and the end date , and then mark n-time steps (i.e. 1 year steps) and finally decide how

Partially color histogram in R

对着背影说爱祢 提交于 2019-11-28 18:24:52
I have a histogram as shown in the picture. I want the bars in the two regions to be coloured red and green respectively, i.e., the bars from 0 to the first black border on the left should be coloured red and the bars in the second region should be coloured green. Can this be done in R? The code used to get the histogram is hist(pr4$x[pr4$x[,1]>-2,1],breaks=100) The best way to do this is to allow hist to do the calculations for you but then use hist (again) to do the actual plotting. Here's an example: set.seed(1) x <- rnorm(1000) h <- hist(rnorm(1000), breaks=50, plot=FALSE) cuts <- cut(h

Plot histogram with colors taken from colormap

♀尐吖头ヾ 提交于 2019-11-28 18:14:58
I want to plot a simple 1D histogram where the bars should follow the color-coding of a given colormap. Here's an MWE : import numpy as n import matplotlib.pyplot as plt # Random gaussian data. Ntotal = 1000 data = 0.05 * n.random.randn(Ntotal) + 0.5 # This is the colormap I'd like to use. cm = plt.cm.get_cmap('RdYlBu_r') # Plot histogram. n, bins, patches = plt.hist(data, 25, normed=1, color='green') plt.show() which outputs this: Instead of the color being green for the entire histogram, I'd like the columns to follow a color-coding given by the colormap defined in cm and the values of the