histogram

How to calculate 3D histogram in python using open CV

老子叫甜甜 提交于 2019-11-30 23:23:20
I want to calculate 3D histogram of my Cielab image in python. I am using openCV to calculate my histogram. I want to compare images using compareHist function of openCV, thats why I am using openCV to compute 3D histogram of my image. I tried with the following variables: i_lab = image.copy() i_lab = i_lab.astype(np.uint8) Range_hist = [[0, 100], [-100, 100], [-100, 100]] hist_1 = cv2.calcHist([i_lab], [[0], [1], [2]], None, [[20], [20], [20]], Range_hist) But it gives error SystemError: error return without exception set Please tell me what am I doing wrong and if it is possible to compute

Creating binned histograms in Spark

谁说我不能喝 提交于 2019-11-30 20:30:23
问题 Suppose I have a dataframe (df) (Pandas) or RDD (Spark) with the following two columns: timestamp, data 12345.0 10 12346.0 12 In Pandas, I can create a binned histogram of different bin lengths pretty easily. For example, to create a histogram over 1 hr, I do the following: df = df[ ['timestamp', 'data'] ].set_index('timestamp') df.resample('1H',how=sum).dropna() Moving to Pandas df from Spark RDD is pretty expensive for me (considering the dataset). Consequently, I prefer to stay within the

How can I create a histogram for all variables in a data set with minimal effort in R?

北慕城南 提交于 2019-11-30 19:50:26
Exploring a new data set: What is the easiest, quickest way to visualise many (all) variables? Ideally, the output shows the histograms next to each other with minimal clutter and maximum information. Key to this question is flexibility and stability to deal with large and different data sets. I'm using RStudio and usually deal with large and messy survey data. One example which comes out of the box of Hmisc and works quite well here is: library(ggplot2) str(mpg) library(Hmisc) hist.data.frame(mpg) Unfortunately, somewhere else I run into problems with data lables (Error in plot.new() : figure

pandas histogram plot error: ValueError: num must be 1 <= num <= 0, not 1

痴心易碎 提交于 2019-11-30 19:43:48
问题 I am drawing a histogram of a column from pandas data frame: %matplotlib notebook import matplotlib.pyplot as plt import matplotlib df.hist(column='column_A', bins = 100) but got the following errors: 62 raise ValueError( 63 "num must be 1 <= num <= {maxn}, not {num}".format( ---> 64 maxn=rows*cols, num=num)) 65 self._subplotspec = GridSpec(rows, cols)[int(num) - 1] 66 # num - 1 for converting from MATLAB to python indexing ValueError: num must be 1 <= num <= 0, not 1 Does anyone know what

How to center labels in histogram plot

我是研究僧i 提交于 2019-11-30 19:07:58
I have a numpy array results that looks like [ 0. 2. 0. 0. 0. 0. 3. 0. 0. 0. 0. 0. 0. 0. 0. 2. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 2. 0. 3. 1. 0. 0. 2. 2. 0. 0. 0. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 0. 2. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 3. 1. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 1. 2. 2.] I would like to plot a histogram of it. I have tried import matplotlib.pyplot as plt plt.hist(results, bins=range(5)) plt.show() This gives me a histogram with the x-axis labelled 0.0 0.5 1.0 1.5 2.0 2.5 3.0. 3.5 4.0 . I would like the x-axis to be

Select data for 15 minute windows - PostgreSQL

孤者浪人 提交于 2019-11-30 18:14:43
问题 Right so I have a table such as this in PostgreSQL: timestamp duration 2013-04-03 15:44:58 4 2013-04-03 15:56:12 2 2013-04-03 16:13:17 9 2013-04-03 16:16:30 3 2013-04-03 16:29:52 1 2013-04-03 16:38:25 1 2013-04-03 16:41:37 9 2013-04-03 16:44:49 1 2013-04-03 17:01:07 9 2013-04-03 17:07:48 1 2013-04-03 17:11:00 2 2013-04-03 17:11:16 2 2013-04-03 17:15:17 1 2013-04-03 17:16:53 4 2013-04-03 17:20:37 9 2013-04-03 17:20:53 3 2013-04-03 17:25:48 3 2013-04-03 17:29:26 1 2013-04-03 17:32:38 9 2013-04

pylab histogram get rid of nan

天涯浪子 提交于 2019-11-30 17:28:24
I have a problem with making a histogram when some of my data contains "not a number" values. I can get rid of the error by using nan_to_num from numpy, but than i get a lot of zero values which mess up the histogram as well. pylab.figure() pylab.hist(numpy.nan_to_num(A)) pylab.show() So the idea would be to make another array in which all the nan values are gone, or to just mask them in the histogram in some way (preferrably with some builtin method). Remove np.nan values from your array using A[~np.isnan(A)] , this will select all entries in A which values are not nan , so they will be

How to draw histogram with same bins width for unequally spaced bins in matplotlib

我的梦境 提交于 2019-11-30 17:26:52
问题 I am trying to draw a histogram with multiple data series in matplotlib. I have unequally spaced bins, however I want that each bin get the same width. So I used attribute width in this way: aa = [0,1,1,2,3,3,4,4,4,4,5,6,7,9] plt.hist([aa, aa], bins=[0,3,9], width=0.2) The result is this: How can I get rid of the margin between two correspondent bins of the two series? I.e. how can I group for each bin the bars of the different series? Thanks 回答1: a solution can be to compute the histogram by

How can I create a histogram for all variables in a data set with minimal effort in R?

半腔热情 提交于 2019-11-30 16:57:13
问题 Exploring a new data set: What is the easiest, quickest way to visualise many (all) variables? Ideally, the output shows the histograms next to each other with minimal clutter and maximum information. Key to this question is flexibility and stability to deal with large and different data sets. I'm using RStudio and usually deal with large and messy survey data. One example which comes out of the box of Hmisc and works quite well here is: library(ggplot2) str(mpg) library(Hmisc) hist.data

Python - Count occurrences of certain ranges in a list

北慕城南 提交于 2019-11-30 15:39:27
So basically I want to count the number of occurrences a floating point appears in a given list. For example: a list of grades (all scores out of 100) are inputted by the user and they are sorted in groups of ten. How many times do scores from 0-10, 10-20, 20-30.. etc) appear? Like test score distribution. I know I can use the count function but since I'm not looking for specific numbers I'm having trouble. Is there a away to combine the count and range? Thanks for any help. To group the data, divide it by the interval width. To count the number in each group, consider using collections