histogram

Draw histograms per row over multiple columns in R

跟風遠走 提交于 2019-11-28 01:22:53
I'm using R for the analysis of my master thesis I have the following data frame: STOF: Student to staff ratio HEI.ID X2007 X2008 X2009 X2010 X2011 X2012 1 OP 41.8 147.6 90.3 82.9 106.8 63.0 2 MO 20.0 20.8 21.1 20.9 12.6 20.6 3 SD 21.2 32.3 25.7 23.9 25.0 40.1 4 UN 51.8 39.8 19.9 20.9 21.6 22.5 5 WS 18.0 19.9 15.3 13.6 15.7 15.2 6 BF 11.5 36.9 20.0 23.2 18.2 23.8 7 ME 34.2 30.3 28.4 30.1 31.5 25.6 8 IM 7.7 18.1 20.5 14.6 17.2 17.1 9 OM 11.4 11.2 12.2 11.1 13.4 19.2 10 DC 14.3 28.7 20.1 17.0 22.3 16.2 11 OC 28.6 44.0 24.9 27.9 34.0 30.7 Then I rank colleges using this commend HEIrank1<-(STOF[,

How to display labels above a histogram bin?

◇◆丶佛笑我妖孽 提交于 2019-11-28 01:17:42
问题 I have an array a(30,2) where the first column is a unique sample number and the second column is a value assigned to the sample. I plot a histogram of the 2nd column: hist(a(:,2)) I have N bins and the y-axis tells me how many samples have a value of x, but no information about which samples are in which bin. How do I plot, above each bin, a list of samples (the number from the first column of my array a ) that fall into each bin? 回答1: As was shown by both @Jonas and @Itamar Katz, the idea

gnuplot histogram: How to put values on top of bars

坚强是说给别人听的谎言 提交于 2019-11-28 00:49:35
问题 I have the following data: 1 3215 2 321 ... 31_60 59 60+ 32 I would like to generate histogram using gnuplot and put the value of bar on top of it. Here is the gnuplot command I tried to create histogram: set style data histogram set xtics rotate plot 'file.dat' using 2:xtic(1) Can someone tell me how to add values on top of the bars generated? I found the following link related histogram (http://gnuplot-tricks.blogspot.com/2009/10/more-on-histograms.html), but didnt get what its doing

Using gnuplot for stacked histograms

≯℡__Kan透↙ 提交于 2019-11-28 00:13:06
问题 I am trying to create a stacked histogram with the following data: 8.01 1 5 1 8.02 3 5 1 8.03 4 4 1 8.04 3 4 1 8.05 1 2 1 I have tried to adapt the script from the 4th example and at the moment I'm using this: set title "Test" set key invert reverse Left outside set key autotitle columnheader set style data histogram set style histogram rowstacked set style fill solid border -1 set boxwidth 0.75 plot 'test.dat' using 2:xtic(1), '' using 2 title 'Col1', '' using 3 title 'Col2', '' using 4

Creating a density histogram in ggplot2?

橙三吉。 提交于 2019-11-27 23:02:55
问题 I want to create the next histogram density plot with ggplot2 . In the "normal" way (base packages) is really easy: set.seed(46) vector <- rnorm(500) breaks <- quantile(vector,seq(0,1,by=0.1)) labels = 1:(length(breaks)-1) den = density(vector) hist(df$vector, breaks=breaks, col=rainbow(length(breaks)), probability=TRUE) lines(den) With ggplot I have reached this so far: seg <- cut(vector,breaks, labels=labels, include.lowest = TRUE, right = TRUE) df = data.frame(vector=vector,seg=seg) ggplot

Stacked histograms like in flow cytometry

你。 提交于 2019-11-27 22:45:28
问题 I'm trying to use ggplot or base R to produce something like the following: I know how to do histograms with ggplot2, and can easily separate them using facet_grid or facet_wrap. But I'd like to "stagger" them vertically, such that they have some overlap, as shown below. Sorry, I'm not allowed to post my own image, and it's quite difficult to find a simpler picture of what I want. If I could, I would only post the top-left panel. I understand that this is not a particularly good way to

Multiple histograms in ggplot2

若如初见. 提交于 2019-11-27 22:19:48
Here is a short part of my data: dat <-structure(list(sex = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("male", "female"), class = "factor"), A = c(1, 2, 0, 2, 1, 2, 2, 0, 2, 0, 1, 2, 2, 0, 0, 2, 0, 0, 0, 2), B = c(0, 0, 0, 0, 0, 2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0), C = c(1, 2, 1, 0, 0, 2, 1, 1, 0, 1, 1, 0, 1, 2, 1, 2, 0, 2, 1, 2), D = c(2, 2, 0, 2, 2, 2, 1, 0, 1, 1, 1, 0, 1, 2, 0, 0, 1, 1, 1, 0), E = c(0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 1, 2, 2), F = c(2, 2, 1, 2, 1, 2, 2, 0, 1, 2, 0, 1, 2, 2, 0, 1, 2, 2, 2,

Setting a relative frequency in a matplotlib histogram

冷暖自知 提交于 2019-11-27 20:31:29
问题 I have data as a list of floats and I want to plot it as a histogram. Hist() function does the job perfectly for plotting the absolute histogram. However, I cannot figure out how to represent it in a relative frequency format - I would like to have it as a fraction or ideally as a percentage on the y-axis. Here is the code: fig = plt.figure() ax = fig.add_subplot(111) n, bins, patches = ax.hist(mydata, bins=100, normed=1, cumulative=0) ax.set_xlabel('Bins', size=20) ax.set_ylabel('Frequency',

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

断了今生、忘了曾经 提交于 2019-11-27 20:30:19
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 . Very easy with Pandas . import pandas from collections import Counter a = ['a', 'a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'd', 'e', 'e', 'e', 'e', 'e'] letter_counts =

Histogram with “negative” logarithmic scale in R

谁说胖子不能爱 提交于 2019-11-27 20:18:50
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 of the first example, except with a kind of "negative log" - i.e. first tick (moving from the centre to