On 09/19/2011 12:49 PM, aurelien wrote:> Dear all,
> I need to compute a joint histogram to compare 2 images (with image()
> function). I wonder if there is any function available in R to do this
> properly?
> Thanks for your help,
> Aurr?lien
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/joint-histogram-for-image-comparison-tp3823800p3823800.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Hi Aurr?lien,
You need to be more specific as to what you want, a reproducible example
would be great. To get a joint (if you meanh by joint that you want to
show the next to each other, not joint in the join probability kind of
way) histogram, I would use ggplot:
library(ggplot2)
dat = data.frame(matrix(runif(10e3), 1000, 10)))
# Convert dat to a flat table
# looking at the result is most illustrative
dat_melt = melt(dat)
head(dat_melt)
# Create the set of 10 histograms
# also works for two, facet_wrap
# the joint histograms
ggplot(aes(x = value), data = dat_melt) + geom_histogram() +
facet_wrap(~ variable)
# The following is purely cosmetic
# Changing some colors
ggplot(aes(x = value), data = dat_melt) + geom_histogram(fill =
"white",
col = "black") + facet_wrap(~ variable)
# Change the theme a bit
theme_set(theme_bw())
ggplot(aes(x = value), data = dat_melt) + geom_histogram(fill
"lightgrey", col = "black") + facet_wrap(~ variable)
hope this helps,
Paul
--
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770