histogram

scatterplotMatrix with group histograms

好久不见. 提交于 2019-12-03 21:45:13
It's pretty easy to build a nice huge scatterplot matrix with histograms down the diagonal for multivariate data as follows: scatterplotMatrix(somedata[1:points.count,],groups=somedata[1:points.count,class], by.groups=TRUE,diagonal="histogram") According to the documentation though, it doesn't seem possible to divide up the histogram by the group labels as is done in this question . How would you do that using scatterplotMatrix or a similar function? Is this what you had in mind? Using the iris dataset: library(ggplot2) library(data.table) library(reshape2) # for melt(...) library(plyr) # for

ggplot2 histogram legend too large

♀尐吖头ヾ 提交于 2019-12-03 21:25:06
I'm pretty happy with the results I'm getting with R. Most of my stacked histogram plots are looking fine, e.g. and However, I have a few that have so many categories in the legend that the legend is crowing out the plot, e.g. How can I fix this? Here is my plot.r, which I call on the command line like this RScript plot.r foo.dat foo.png 1600 800 foo.dat account,operation,call_count,day cal3510,foo-method,1,2016-10-01 cra4617,foo-method,1,2016-10-03 cus4404,foo-method,1,2016-10-03 hin4510,foo-method,1,2016-10-03 mas4484,foo-method,1,2016-10-04 ... entirety of foo.dat: http://pastebin.com

I need ggplot scale_x_log10() to give me both negative and positive numbers as output

蓝咒 提交于 2019-12-03 20:59:09
I generate a fine histogram here with both positive and negative numbers. x <- rnorm(5000,0,1000) library(ggplot2) df <- data.frame(x) ggplot(df, aes(x = x)) + geom_histogram() What I want is to have a logged x-axis. When I do this for only positive numbers with scale_x_log10(), it works like a charm. But here it does not and it either removes my negative numbers are adds them to the positive numbers. ggplot(df, aes(x = x)) + geom_histogram() + scale_x_log10() All I really want is for the ticks and the spacing between the ticks to follow the log pattern and for either side of 0 on the x-axis

Histogram matching of two colored images in matlab

一曲冷凌霜 提交于 2019-12-03 19:21:20
问题 Anyone knows how to perform RGB histogram matching on two colored images? for example this is an image to be re-mapped: and this is a target image Then the RGB remapped image look like this here is what I did so far, in this code I took two color images im1 and im2 I took the im1 which is the one that has to be remapped then broke it up into its colors then I took each color of im1 and used histeq to match their histograms to each color in im2 . I don't know how to reconstruct the re-mapped

Set number of bins for histogram directly in ggplot

£可爱£侵袭症+ 提交于 2019-12-03 17:52:59
问题 I'd like to feed geom_histogram the number of bins for my histogram instead of controlling bins through binwidth . The documentation says I can do this by setting the bins argument. But when I run ggplot(data = iris, aes(x = Sepal.Length)) + stat_bin(bins = 5) I get an output message with 30 bins, as if I didn't specify binwidth at all. stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this. I've tried feeding this argument to stat_bin and qplot with the same problem. Am

Can't add a probability-curve on the histogram

倖福魔咒の 提交于 2019-12-03 17:14:47
I'm trying do display multiple histograms with one plot with the lattice-package. That's my code so far: histogram(~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10, data=mydata, type = "density",layout=c(5,2), panel=function(x, ...) { panel.histogram(x, ...) panel.mathdensity(dmath=dnorm, col="black", args=list(mean=mean(x), sd=sd(x)), ...) }) The problem is, that it won't plot the probability-curve. It doesn't give me an error back, so the code looks good, I think. I also tried it with only one variable and it didn't work either: histogram(~ X1, data=mydata, type = "density",layout=c(5,2),

Add a vertical line with different intercept for each panel in ggplot2

南笙酒味 提交于 2019-12-03 17:13:02
问题 I'm using ggplot2 to create panels of histograms, and I'd like to be able to add a vertical line at the mean of each group. But geom_vline() uses the same intercept for each panel (i.e. the global mean): require("ggplot2") # setup some sample data N <- 1000 cat1 <- sample(c("a","b","c"), N, replace=T) cat2 <- sample(c("x","y","z"), N, replace=T) val <- rnorm(N) + as.numeric(factor(cat1)) + as.numeric(factor(cat2)) df <- data.frame(cat1, cat2, val) # draws a single histogram with vline at mean

D3 Histogram - Date Based

空扰寡人 提交于 2019-12-03 17:03:52
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 dates. Basically like this example: http://bl.ocks.org/mbostock/3048450 But instead of showing random

R: ggplot2: Adding count labels to histogram with density overlay

独自空忆成欢 提交于 2019-12-03 16:50:20
I have a time-series that I'm examining for data heterogeneity, and wish to explain some important facets of this to some data analysts. I have a density histogram overlayed by a KDE plot (in order to see both plots obviously). However the original data are counts, and I want to place the count values as labels above the histogram bars. Here is some code: $tix_hist <- ggplot(tix, aes(x=Tix_Cnt)) + geom_histogram(aes(y = ..density..), colour="black", fill="orange", binwidth=50) + xlab("Bin") + ylab("Density") + geom_density(aes(y = ..density..),fill=NA, colour="blue") + scale_x_continuous

r : ecdf over histogram

℡╲_俬逩灬. 提交于 2019-12-03 16:35:53
in R, with ecdf I can plot a empirical cumulative distribution function plot(ecdf(mydata)) and with hist I can plot a histogram of my data hist(mydata) How I can plot the histogram and the ecdf in the same plot? EDIT I try make something like that https://mathematica.stackexchange.com/questions/18723/how-do-i-overlay-a-histogram-with-a-plot-of-cdf symbolrush Also a bit late, here's another solution that extends @Christoph 's Solution with a second y-Axis. par(mar = c(5,5,2,5)) set.seed(15) dt <- rnorm(500, 50, 10) h <- hist( dt, breaks = seq(0, 100, 1), xlim = c(0,100)) par(new = T) ec <- ecdf