histogram

Python: how to make an histogram with equally *sized* bins

情到浓时终转凉″ 提交于 2019-12-03 13:03:47
I have a set of data, and want to make an histogram of it. I need the bins to have the same size , by which I mean that they must contain the same number of objects, rather than the more common (numpy.histogram) problem of having equally spaced bins. This will naturally come at the expenses of the bins widths, which can - and in general will - be different. I will specify the number of desired bins and the data set, obtaining the bins edges in return. Example: data = numpy.array([1., 1.2, 1.3, 2.0, 2.1, 2.12]) bins_edges = somefunc(data, nbins=3) print(bins_edges) >> [1.,1.3,2.1,2.12] So the

Adding key legend to multi-histogram plot in R

非 Y 不嫁゛ 提交于 2019-12-03 12:38:18
问题 How do I add a key legend to the below plot I whish to have a key legend somewhere in the upper right corner with two short horizontal color bars, where the red one should say "Plastic surgery gone wrong" and the blue one should say "Germany". I used the following code to produce the plot: bar2 <- read.table("div/ana-mut[...]/barriers-set-2.dat", sep=" ") bar2val <- c(bar2$V1, bar2$V2) bar3 <- read.table("div/ana-mut[...]/barriers-set-3.dat", sep=" ") bar3val <- c(bar3$V1, bar3$V2) p1 <- hist

Creating a 3D histogram with R

偶尔善良 提交于 2019-12-03 11:35:50
How can I create a 3D histogram with R? For example, I have two variables to be counted for the number of times they fall in a defined two dimensional bin. So I have two variables in the X and Y axis, while the Z axis is the count of the two variables. cbeleites supports Monica have a look at package hexbin to calculate and display, or e.g. ggplot's stat_bin2d / stat_binhex for display. You get 2 spatial coordinates which is all your screen or paper can do plus a 3rd, colour-coded dimension. Note that How does one plot a 3D stacked histogram in R? is quite a duplicate of this question (but the

How to create the histogram of an array with masked values, in Numpy?

三世轮回 提交于 2019-12-03 11:34:59
In Numpy 1.4.1, what is the simplest or most efficient way of calculating the histogram of a masked array? numpy.histogram and pyplot.hist do count the masked elements, by default! The only simple solution I can think of right now involves creating a new array with the non-masked value: histogram(m_arr[~m_arr.mask]) This is not very efficient, though, as this unnecessarily creates a new array. I'd be happy to read about better ideas! (Undeleting this as per discussion above...) I'm not sure whether or not the numpy developers would consider this a bug or expected behavior. I asked on the

Faster way to extract histogram from an image

若如初见. 提交于 2019-12-03 11:21:21
I'm looking for a faster way to extract histogram data from an image. I'm currently using this piece of code that needs about 1200ms for a 6mpx JPEG image: ImageReader imageReader = (ImageReader) iter.next(); imageReader.setInput(is); BufferedImage image = imageReader.read(0); int height = image.getHeight(); int width = image.getWidth(); Raster raster = image.getRaster(); int[][] bins = new int[3][256]; for (int i = 0; i < width; i++) for (int j = 0; j < height; j++) { bins[0][raster.getSample(i, j, 0)]++; bins[1][raster.getSample(i, j, 1)]++; bins[2][raster.getSample(i, j, 2)]++; } Do you

Image detection features: SIFT, HISTOGRAM and EGDE

≯℡__Kan透↙ 提交于 2019-12-03 10:16:47
问题 I am working on developing a object classifier by using 3 different features i.e SIFT, HISTOGRAM and EGDE. However these 3 features have different dimensional vector e.g. SIFT = 128 dimension. HIST = 256. Now these features cannot be concatenated into once vector due to different sizes. What I am planning to do but I am not sure if it is going to be correct way is this: For each features i train the classifier separately and than i apply classification separately for 3 different features and

Histogram with breaking axis and interlaced colorbar

荒凉一梦 提交于 2019-12-03 10:16:41
问题 I have data as those ones a b c d e alpha 5.51 0.60 -0.12 26.90 76284.53 beta 3.39 0.94 -0.17 -0.20 -0.20 gamma 7.98 3.34 -1.41 7.74 28394.93 delta 2.29 1.24 0.40 0.29 0.28 I want to do a nice publishable histogram as this one but with a break in the y axis so we can figure out the variation of a , b , c , d and e so that data will not be squashed by extreme values in e column as this one but using interlaced colorbar histogram: I would like to do that in python (matplotlib, pandas, numpy

How to recognize histograms with a specific shape in opencv / python

≡放荡痞女 提交于 2019-12-03 10:03:30
问题 I want to segment images (from magazines) in text and image parts. I have several histograms for several ROIs in my picture. I use opencv with python (cv2). I want to recognize histograms that look like this http://matplotlib.sourceforge.net/users/image_tutorial-6.png as it is a typical shape for a text region. How can I do that? Edit: Thank you for your help so far. I compared the histograms I got from my ROIs to a sample histogram I provided: hist = cv2.calcHist(roi,[0,1], None, [180,256]

R Normalize then plot two histograms together in R

梦想与她 提交于 2019-12-03 09:49:50
问题 I realize there have been several posts for people asking how to plot two histograms together side by side (as in one plot with the bars next to each other) and overlaid in R and also on how to normalize data. Following the advice that I've found, I'm able to do one or the other, but not both operations. Here's the setup. I have two data frames of different lengths and would like to plot the volume of the objects in each df as a histogram. Eg how many in data frame 1 are between .1-.2 um^3

Python: Creating a 2D histogram from a numpy matrix

老子叫甜甜 提交于 2019-12-03 09:17:15
问题 I'm new to python. I have a numpy matrix, of dimensions 42x42, with values in the range 0-996. I want to create a 2D histogram using this data. I've been looking at tutorials, but they all seem to show how to create 2D histograms from random data and not a numpy matrix. So far, I have imported: import numpy as np import matplotlib.pyplot as plt from matplotlib import colors I'm not sure if these are correct imports, I'm just trying to pick up what I can from tutorials I see. I have the numpy