histogram

R - hist3D of sequence colour and label issues

扶醉桌前 提交于 2019-12-10 17:41:52
问题 So I have a dataset with 5 rows and 20 columns. I am trying to plot a hist3D from the plot3D package. dt = structure(c(1, 1, 1, 3, 1, 2, 1, 0, 2, 1, 2, 1, 0, 1, 1, 0, 1, 0, 2, 2, 1, 1, 1, 1, 4, 4, 1, 1, 2, 3, 8, 1, 1, 2, 1, 10, 0, 1, 2, 1, 9, 0, 2, 4, 0, 4, 0, 5, 2, 2, 2, 0, 1, 2, 4, 1, 1, 3, 2, 6, 8, 1, 2, 2, 4, 10, 0, 2, 2, 4, 7, 0, 7, 1, 4, 11, 0, 4, 1, 2, 15, 0, 4, 2, 3, 16, 2, 7, 2, 2, 18, 3, 9, 0, 1, 15, 0, 15, 0, 2), .Dim = c(5L, 20L), .Dimnames = list(c("f Housework", "g Odd jobs", "h

Is there a more elegant replacement for this MATLAB loop?

徘徊边缘 提交于 2019-12-10 17:20:00
问题 I want to get better at vectorizing my loops in MATLAB. At the moment, I'm trying to count the occurrences of values in a list of ints. My code is similar to this: list = [1 2 2 3 1 3 2 2 2 1 5]; occurrence_list = zeros(1,max(list)); for x=list occurrence_list(x) = occurrence_list(x) + 1; end Is there a simple vectorized replacement for that for loop? (Or is there a built in MATLAB function that I'm missing?) I'm doing this on pretty small data sets, so time isn't an issue. I just want to

Plotting a histogram using a range of values and their frequency as a dictionary

被刻印的时光 ゝ 提交于 2019-12-10 17:18:16
问题 Assume that I have the following dictionary: scenario_summary = {'Day1': {'22459-22585': 0.0, '22585-22711': 0.0, '22711-22837': 0.0, '22837-22963': 0.0, '22963-23089': 0.0, '23089-23215': 0.0, '23215-23341': 0.0, '23341-23467': 0.0, '23467-23593': 0.0, '23593-23719': 0.0, '23719-23845': 0.0, '23845-23971': 0.0, '23971-24097': 0.0, '24097-24223': 0.0, '24223-24349': 0.0, '24349-24475': 0.0, '24475-24601': 0.0, '24601-24727': 0.0, '24727-24853': 0.0, '24853-24979': 0.0, '24979-25105': 0.0,

Binning frequency distribution in Python

女生的网名这么多〃 提交于 2019-12-10 15:48:28
问题 I have data in the two lists value and freq like this: value freq 1 2 2 1 3 3 6 2 7 3 8 3 .... and I want the output to be bin freq 1-3 6 4-6 2 7-9 6 ... I can write few lines of code to do this. However, I am looking if there are builitin functions in standard python or Numpy? I found the solution when you are given data in array/list with repetition i.e. they are not already grouped into frequency table(eg. d= [1,1,2,3,3,3,6,6,7,7,7,8,8,8,...] . However, in this case I could not find the

Numpy histogram on multi-dimensional array

那年仲夏 提交于 2019-12-10 15:39:48
问题 given an np.array of shape (n_days, n_lat, n_lon) , I'd like to compute a histogram with fixed bins for each lat-lon cell (ie the distribution of daily values). A simple solution to the problem is to loop over the cells and invoke np.histogram for each cell:: bins = np.linspace(0, 1.0, 10) B = np.rand(n_days, n_lat, n_lon) H = np.zeros((n_bins, n_lat, n_lon), dtype=np.int32) for lat in range(n_lat): for lon in range(n_lon): H[:, lat, lon] = np.histogram(A[:, lat, lon], bins=bins)[0] # note:

R: ggplot: Error: Unknown parameters: binwidth, bins, pad

余生长醉 提交于 2019-12-10 15:33:23
问题 I want to do a very simple histogram with ggplot2. I have the following MWE: library(ggplot2) mydf <- data.frame( Gene=c("APC","FAT4","XIRP2","TP53","CSMD3","BAI3","LRRK2","MACF1", "TRIO","SETD2","AKAP9","CENPF","ERBB4","FBXW7","NF1","PDE4DIP", "PTPRT","SPEN","ATM","FAT1","SDK1","SMG1","GLI3","HIF1A","ROS1", "BRDT","CDH11","CNTRL","EP400","FN1","GNAS","LAMA1","PIK3CA", "POLE","PRDM16","ROCK2","TRRAP","BRCA2","DCLK1","EVC2","LIFR", "MAST4","NAV3"), Freq=c(48,39,35,28,26,17,17,17,16,15,14,14,14

PCL Point Feature Histograms - binning

雨燕双飞 提交于 2019-12-10 15:27:53
问题 The binning process, which is part of the point feature histogram estimation, results in b^3 bins if only the three angular features (alpha, phi, theta) are used, where b is the number of bins. Why is it b^3 and not b * 3 ? Let's say we consider alpha. The feature value range is subdivided into b intervals. You iterate over all neighbors of the query point and count the amount of alpha values which lie in one interval. So you have b bins for alpha. When you repeat this for the other two

Change outline and fill colors of histogram with qplot

时光毁灭记忆、已成空白 提交于 2019-12-10 14:37:00
问题 I have two histograms in one window (using facet) and I would like control over the color of the outline and the fill. I've tried looking up color scales , aes() , + color , + fill , including color and fill in qplot , all resulting in expected plots! My code can be found below. (Note: mussel2 has two columns concentration (a list of numbers) and waterbody (listed or reference). I can provide the data if necessary. I understand this is an elementary question, so I do appreciate your time.

Unable to align bins in a histogram of datetime objects using the hist() function

本小妞迷上赌 提交于 2019-12-10 13:54:05
问题 So I am trying to plot a histogram of some datetime objects, but i can never get the bins to line up with the bars. My code is below: I start by importing my stuff and declaring the start, end and a one day object: import datetime import matplotlib.pyplot as plt end = datetime.date(2017,5,14) start = datetime.date(2017,5,8) one_day = datetime.timedelta(days = 1) Then I declare an arbitrary list of dates: date_list = [datetime.date(2017,5,14), datetime.date(2017,5,14), datetime.date(2017,5,14)

Hide histogram plot

送分小仙女□ 提交于 2019-12-10 13:44:53
问题 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, normed=True); pdf = 1/(sigma * np.sqrt(2 * np.pi)) * np.exp(- (bins - mu)**2 / (2 * sigma**2)) mu_ = 10 sigma_ = 1 s = np.random.normal(mu_, sigma_, 1000) count_, bins_, ignored_ = plt.hist(s, 100, normed=True); pdf_ = 1/(sigma_ * np.sqrt(2 * np.pi)) *