histogram

Use hist() function in R to get percentages as opposed to raw frequencies

佐手、 提交于 2019-12-17 18:03:27
问题 How can one plot the percentages as opposed to raw frequencies using the hist() function in R? 回答1: Simply using the freq=FALSE argument does not give a histogram with percentages, it normalizes the histogram so the total area equals 1. To get a histogram of percentages of some data set, say x, do: h = hist(x) # or hist(x,plot=FALSE) to avoid the plot of the histogram h$density = h$counts/sum(h$counts)*100 plot(h,freq=FALSE) Basically what you are doing is creating a histogram object,

Histogram matching of two images in Python 2.x?

左心房为你撑大大i 提交于 2019-12-17 17:36:13
问题 I'm trying to match the histograms of two images (in MATLAB this could be done using imhistmatch). Is there an equivalent function available from a standard Python library? I've looked at OpenCV, scipy, and numpy but don't see any similar functionality. 回答1: I previously wrote an answer here explaining how to do piecewise linear interpolation on an image histogram in order to enforce particular ratios of highlights/midtones/shadows. The same basic principles underlie histogram matching

How to label histogram bars with data values or percents in R

只谈情不闲聊 提交于 2019-12-17 17:27:30
问题 I'd like to label each bar of a histogram with either the number of counts in that bin or the percent of total counts that are in that bin. I'm sure there must be a way to do this, but I haven't been able to find it. This page has a couple of pictures of SAS histograms that do basically what I'm trying to do (but the site doesn't seem to have R versions): http://www.ats.ucla.edu/stat/sas/faq/histogram_anno.htm If possible, it would also be nice to have the flexibility to put the labels above

How to make a dynamic frequency histogram from user input

帅比萌擦擦* 提交于 2019-12-17 16:54:36
问题 Object fileButton = null; if("Analyze Text File".equals(command)) { JFileChooser filechooser; JFileChooser chooser = new JFileChooser(); int returnVal = filechooser.showOpenDialog(getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = filechooser.getSelectedFile(); String Stext = (String) readFileAsString(file); //String text = textInput.getText(); Map<Integer, Integer> counts = getCounts(text); int width = counts.size() * BAR_WIDTH; int max = maxCount(counts); int height =

R - Customizing X Axis Values in Histogram

99封情书 提交于 2019-12-17 16:34:18
问题 I want to change the values on the x axis in my histogram in R. The computer currently has it set as 0, 20, 40, 60, 80, 100. I want the x axis to go by 10 as in: 0,10,20,30,40,50,60,70,80,90,100. I know to get rid of the current axis I have to do this (hist(x), .... xaxt = 'n') and then axis(side = 1) ..... But how do I get it to show the numbers that I need it to show? Thanks. 回答1: The answer is right there in ?axis ... dat <- sample(100, 1000, replace=TRUE) hist(dat, xaxt='n') axis(side=1,

How to make a histogram from a list of strings in Python?

无人久伴 提交于 2019-12-17 15:54:27
问题 I have a list of strings: a = ['a', 'a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'd', 'e', 'e', 'e', 'e', 'e'] I want to make a histogram for displaying the frequency distribution of the letters. I can make a list that contains the count of each letter using following codes: from itertools import groupby b = [len(list(group)) for key, group in groupby(a)] How do I make the histogram? I may have a million such elements in list a . 回答1: Very easy with Pandas . import pandas from collections import

Histogram with “negative” logarithmic scale in R

萝らか妹 提交于 2019-12-17 15:52:22
问题 I have a dataset with some outliers, such as the following x <- rnorm(1000,0,20) x <- c(x, 500, -500) If we plot this on a linear x axis scale at this we see histogram(x) I worked out a nice way to put it on a log scale using this useful thread: how to use a log scale for y-axis of histogram in R? : mat <- data.frame(x) ggplot(ee, aes(x = xx)) + geom_histogram(colour="darkblue", size=1, fill="blue") + scale_x_log10() However, I would like the x axis labels from this 2nd example to match that

iOS GLSL. Is There A Way To Create An Image Histogram Using a GLSL Shader?

不羁的心 提交于 2019-12-17 15:36:55
问题 Elsewhere on StackOverflow a question was asked regarding a depthbuffer histogram - Create depth buffer histogram texture with GLSL. I am writing an iOS image-processing app and am intrigued by this question but unclear on the answer provided. So, is it possible to create an image histogram using the GPU via GLSL? 回答1: Yes, it is. It's not clearly the best approach, but it's indeed the best one available in iOS, since OpenCL is not supported. You'll lose elegance, and your code will probably

How can I change the color of bars in bar graph?

China☆狼群 提交于 2019-12-17 14:21:32
问题 I'd like to create a bar graph where I change the color of some bars. The code for my bar graph is the following: y = [0.04552309, -0.001730885, 0.023943445, 0.065564478, 0.032253892, 0.013442562, ... -0.011172323, 0.024595622, -0.100614203, -0.001444697, 0.019383706, 0.890249809]; bar(y) I want the first six bars to be black and the last 6 bars to be blue, but I have no idea how to do it. 回答1: You need to plot them separately (but on the same axes): bar(1:6,y(1:6),'k') hold on bar(7:numel(y)

How can I change the color of bars in bar graph?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 14:21:32
问题 I'd like to create a bar graph where I change the color of some bars. The code for my bar graph is the following: y = [0.04552309, -0.001730885, 0.023943445, 0.065564478, 0.032253892, 0.013442562, ... -0.011172323, 0.024595622, -0.100614203, -0.001444697, 0.019383706, 0.890249809]; bar(y) I want the first six bars to be black and the last 6 bars to be blue, but I have no idea how to do it. 回答1: You need to plot them separately (but on the same axes): bar(1:6,y(1:6),'k') hold on bar(7:numel(y)