Easy to write - here's a quick piece of code (without bells and whistles
though...)
dat1 <- rnorm(1000)
dat2 <- rgamma(3000, shape=3)
biHist <- function(d1, d2) {
col1 <- "#FFCCBB"
col2 <- "#BBCCFF"
hAll <- hist(c(d1, d2))
hD1 <- hist(d1, breaks=hAll$breaks)
hD2 <- hist(d2, breaks=hAll$breaks)
plot(NULL,
xlim = c(-1.05 * max(hD1$counts), 1.05 * max(hD2$counts)),
ylim = c(min(hAll$breaks), max(hAll$breaks)),
xlab = "frequencies",
ylab = "values",
xaxt = "n")
axis(side = 1,
lwd = 0,
lwd.ticks = 1,
at = axTicks(1),
labels = abs(axTicks(1)))
abline(v = 0)
rect(-hD1$counts,
hAll$breaks[-length(hAll$breaks)],
0,
hAll$breaks[-1],
col=col1)
rect(0,
hAll$breaks[-length(hAll$breaks)],
hD2$counts,
hAll$breaks[-1],
col=col2)
}
biHist(dat1, dat2)
Let me know in case this needs modifications that you can't easily make yourself
:-)
B.
On Jun 2, 2015, at 4:43 PM, David Winsemius <[email protected]> wrote:
>
> On Jun 2, 2015, at 11:13 AM, Dan Abner wrote:
>
>> Hi all,
>>
>> Does anyone know how to create a graph of propensity scores like the
>> one on the left in the attachment? I can easily generate the one on
>> the right: How does one force the respective histograms to share the
>> same rotated x-axis? Is it possible to set the horizontal white space
>> between these to graphs to 0 so that there is only the single line
>> running down the middle of the graph?
>>
>
> I think you will find that "pyramid" plots of this sort are in some packages
> and that similar requests (to get rid of the middle space) have been made in
> the past. Pyramid plots are often used by demographers to compare and display
> age distributions of both genders. Why not see if that work can be found with
> a search engine. I use this MarkMail link on my browser to search the Archive
>
> http://markmail.org/search/?q=list%3Aorg.r-project.r-help
>
> ....(but you could also direct the Google Advanced Search function to the
> real Archives if you wanted:
>
> https://stat.ethz.ch/pipermail/r-help/
>
>
>> Thanks,
>>
>> Dan
>> <graphs.pdf>______________________________________________
>> [email protected] mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
> David Winsemius
> Alameda, CA, USA
>
> ______________________________________________
> [email protected] mailing list -- To UNSUBSCRIBE and more, see
> 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.
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
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.