histogram

Plot Histogram with Points Instead of Bars

故事扮演 提交于 2019-11-29 06:46:54
Here is a question for R-users. I am interested in drawing a histogram with points stacked up, instead of a bar. For example if the data is (1,1,2,1,2,3,3,3,4,4), then I would like to see three points stacked up at 1, 2 points stacked up at 2 and so on. What is the best way to do this in R? Solomon Choe Greg Snow's TeachingDemos package contains a dots(x, ...) function which seems to fit your need: dots( round( rnorm(50, 10,3) ) ) You can do this yourself pretty quickly: x <- c(1,1,2,1,2,3,3,3,4,4) plot(sort(x), sequence(table(x))) The simplest answer I know is this: x <- c(1,1,2,1,2,3,3,3,4,4

Using gnuplot for stacked histograms

为君一笑 提交于 2019-11-29 06:45:57
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 title 'Col3' The part I copied which I'm not sure about is using 2:xtic(1) . I know this makes it use the

Stacked histograms like in flow cytometry

早过忘川 提交于 2019-11-29 05:22:18
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 display data -- but that decision does not rest with me. A sample dataset would be as follows: my.data <- as

Histogram equalization of grayscale images with NumPy

人走茶凉 提交于 2019-11-29 04:51:29
How to do histogram equalization for multiple grayscaled images stored in a NumPy array easily? I have the 96x96 pixel NumPy data in this 4D format: (1800, 1, 96,96) Trilarion Moose's comment which points to this blog entry does the job quite nicely. For completeness I give an axample here using nicer variable names and a looped execution on 1000 96x96 images which are in a 4D array as in the question. It is fast (1-2 seconds on my computer) and only needs NumPy. import numpy as np def image_histogram_equalization(image, number_bins=256): # from http://www.janeriksolem.net/2009/06/histogram

SuperImpose Histogram fits in one plot ggplot

二次信任 提交于 2019-11-29 04:13:00
问题 I have ~ 5 very large vectors (~ 108 MM entries) so any plot/stuff I do with them in R takes quite long time. I am trying to visualize their distribution (histogram), and was wondering what would be the best way to superimpose their histogram distributions in R without taking too long. I am thinking to first fit a distribution to the histogram, and then plot all the distribution line fits together in one plot. Do you have some suggestions on how to do that? Let us say my vectors are: x1, x2,

Multiple histograms in Pandas

微笑、不失礼 提交于 2019-11-29 03:18:30
I would like to create the following histogram (see image below) taken from the book "Think Stats". However, I cannot get them on the same plot. Each DataFrame takes its own subplot. I have the following code: import nsfg import matplotlib.pyplot as plt df = nsfg.ReadFemPreg() preg = nsfg.ReadFemPreg() live = preg[preg.outcome == 1] first = live[live.birthord == 1] others = live[live.birthord != 1] #fig = plt.figure() #ax1 = fig.add_subplot(111) first.hist(column = 'prglngth', bins = 40, color = 'teal', \ alpha = 0.5) others.hist(column = 'prglngth', bins = 40, color = 'blue', \ alpha = 0.5)

add horizontal line histogram gnuplot

喜夏-厌秋 提交于 2019-11-29 02:13:02
I would like to add a horizontal line in my histogram in gnuplot, is that possible? My histogram has on the x axis: alea1 alea 2 alea3 nalea1 nalea 2 nalea 3 and the y axis goes from 0 to 25. At 22, I want to add a horizontal line that goes all the way across from one end to the other end of the histogram. Try adding , 22 title "" at the end of your plot command. Works for my test data (file "histo"): # Year Red Green Blue 1990 33 45 18 1991 35 42 19 1992 34 44 14 1993 37 43 25 1994 47 15 30 1995 41 14 32 1996 42 20 35 1997 39 21 31 plot "histo" u 2 t "Red" w histograms, "" u 3 t "Green" w

Formatting histogram x-axis when working with dates using R

半城伤御伤魂 提交于 2019-11-29 02:02:24
I am in the process of creating an epidemic curve (histogram of number of cases of a disease per day) using R, and am struggling a little with formatting the x-axis. I am aware that ggplot gives very nice graphs and easily manipulatable axes ( Understanding dates and plotting a histogram with ggplot2 in R ), but in this case I prefer to use the hist() command, because I am describing 2 different patterns at the same time, as below (I don't think you can do something similar in ggplot): The problem here is that the x-axis does not begin at the first case, has too many tick marks, and I'd like

add title to collection of pandas hist plots

爱⌒轻易说出口 提交于 2019-11-29 01:50:36
问题 I'm looking for advice on how to show a title at the top of a collection of histogram plots that have been generated by a pandas df.hist() command. For instance, in the histogram figure block generated by the code below I'd like to place a general title (e.g. 'My collection of histogram plots') at the top of the figure: data = DataFrame(np.random.randn(500).reshape(100,5), columns=list('abcde')) axes = data.hist(sharey=True, sharex=True) I've tried using the title keyword in the hist command

R: saving ggplot2 plots in a list

ぐ巨炮叔叔 提交于 2019-11-29 01:33:41
I am writing a R code that allows users to select columns from a data and plots histograms for each of them. Hence, I am using a 'for' loop to generate the required number of plots using the ggplot2 library and save them in a single list. But the problem I am facing is that, at every iteration of the 'for' loop, all objects in the list are storing the same plot. Thus, the final output consists of a grid of histograms, labeled differently but depicting the same(last) column. I understand that this question is quite old and I found the answers on renaming ggplot2 graphs in a for loop and https:/