histogram

How to plot a density estimate on top of the histogram? [duplicate]

旧街凉风 提交于 2019-12-09 19:00:47
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Fitting a density curve to a histogram in R x is a NAs free numeric vector. I run: > hist(x,density(x), prob=TRUE) Error Message I get: Error in rank(x, ties.method = "min", na.last = "keep") : unimplemented type 'list' in 'greater' It was suggested that I set prob =TRUE when calling hist. If you can explain that as well, it will be great. Thank you. 回答1: You need to call hist and density separately. Something

D3 Histogram - Date Based

a 夏天 提交于 2019-12-09 13:37:56
问题 I have an array of dates ["01/01/2001", "01/01/2001", "03/01/2001", "01/04/2001", "01/05/2001", "02/05/2001", "01/07/2001", "01/07/2001", "01/07/2001", "01/10/2001"] Some are duplicates and in no particular order, over a varying timescale (1 week, 43 days, 2 years etc). What I want to do is produce a histogram (or bar chart) that shows counts of "dates" in arbitrary # of buckets (like 20 buckets). Where there are no dates in a bucket it shows zero and a total for those buckets that contain

d3.js - controlling ticks and bins on a histogram

倖福魔咒の 提交于 2019-12-09 07:13:00
问题 I'm trying to build a histogram script that compares values within, say, 20% of some "focus" value. So, for a focus value of 75, I'd look at values ranging from 60 to 90. I want a predetermined, odd number of bins/bars, with the middle bin/bar containing the focus value (75). Some bins may have a count of zero. My problem and question has to do with how to control the number of bins, and the number of ticks. I want the ticks between the bars. I want to say "7 bins" and get 7 bars, with 8

color percentage in image python opencv using histogram

ぐ巨炮叔叔 提交于 2019-12-09 07:08:25
问题 I am beginner in python and image processing. I want to find the percentage of brown color from an image using histogram function. I did the histogram function but I do not know how to find the percentage of the brown color in the image. this is my python code import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('C:\Users\MainUser\Desktop\histogram\dates.jpg', -1) cv2.imshow('GoldenGate',img) color = ('b','g','r') for channel,col in enumerate(color): histr = cv2

How to create black and white transparent overlapping histograms using ggplot2?

给你一囗甜甜゛ 提交于 2019-12-09 05:59:41
问题 I used ggplot2 to create two transparent overlapping histograms. test = data.frame(condition = rep(c("a", "b"), each = 500), value = rep(-1, 1000)) test[1:500,]$value = rnorm(500) test[501:1000,]$value = rnorm(500) + 2 fig = ggplot(test, aes(x = value, fill = condition)) + #scale_fill_grey() + geom_histogram(position = "identity", alpha = .5) fig The resulting plot looks great, but it's in color. I need a grayscale or black/white plot. Using "scale_fill_grey()" results in a plot with

Scala simple histogram

a 夏天 提交于 2019-12-09 02:49:24
问题 For a given Array[Double] , for instance val a = Array.tabulate(100){ _ => Random.nextDouble * 10 } what is a simple approach to calculate a histogram with n bins ? 回答1: A very similar preparation of values as in @om-nom-nom 's answer, yet the histogram method quite small by using partition , case class Distribution(nBins: Int, data: List[Double]) { require(data.length > nBins) val Epsilon = 0.000001 val (max,min) = (data.max,data.min) val binWidth = (max - min) / nBins + Epsilon val bounds =

Stacked histogram from already summarized counts using ggplot2

£可爱£侵袭症+ 提交于 2019-12-08 23:45:24
问题 I would like some help coloring a ggplot2 histogram generated from already-summarized count data. The data are something like counts of # males and # females living in a number of different areas. It's easy enough to plot the histogram for the total counts (i.e. males + females): set.seed(1) N=100; X=data.frame(C1=rnbinom(N,15,0.1), C2=rnbinom(N,15,0.1),C=rep(0,N)); X$C=X$C1+X$C2; ggplot(X,aes(x=C)) + geom_histogram() However, I'd like to color each bar according to the relative contribution

access to bin counts in seaborn distplot

点点圈 提交于 2019-12-08 19:14:12
问题 In pyplot's hist() function, we are able to access the values of the histogram bins (through the return n ); is it possible to access this same information from Seaborn's distplot? Seaborn only returns an axis object. Ultimately, I'd like juxtapose a line plot on top of the histogram which sums the counts in the bins. 回答1: For completeness, numpy.histogram is what I was looking for! 来源: https://stackoverflow.com/questions/31727280/access-to-bin-counts-in-seaborn-distplot

Spacing between bars in matplotlib hist() with thousands of bins

邮差的信 提交于 2019-12-08 18:52:13
问题 I'm making histograms using matplotlib's hist() function or bar(), and I want to use >10,000 bins (one bin to represent the counts at each coordinate of a large entity). Is there any way to create more whitespace between the vertical bars when I create the figure? Currently, there is no whitespace between each bar of the histogram. For example: # imports import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np import random # Generating dummy data coordinate

OpenCV C++ calcHist to Java

拟墨画扇 提交于 2019-12-08 17:25:34
I'm trying to get some c++ code to run on my Android device; however, I'm running into a small little problem with the type of Mat I'm using. The code I'm trying to convert is as follow (the second function calls the first): static Mat histc_(const Mat& src, int minVal=0, int maxVal=255, bool normed=false) { Mat result; // Establish the number of bins. int histSize = maxVal-minVal+1; // Set the ranges. float range[] = { static_cast<float>(minVal), static_cast<float>(maxVal+1) }; const float* histRange = { range }; // calc histogram calcHist(&src, 1, 0, Mat(), result, 1, &histSize, &histRange,