
require(UsingR) x=rnorm(999) y=x+rnorm(999) simple.scatterplot(x,y) André Oliveira Souza Em Domingo, 15 de Dezembro de 2013 15:50, Andre Oliveira <andreolsouza@yahoo.com.br> escreveu: André Oliveira Souza Em Domingo, 15 de Dezembro de 2013 11:35, Rodrigo Coster <rcoster@gmail.com> escreveu: Acho que tu nao entrou no link que eu falei... Enfim, segue o texto do link (http://www.r-bloggers.com/example-10-3-enhanced-scatterplot-with-marginal-hi...) scatterhist <- function(x, y, xlab = "", ylab = "", plottitle="", xsize=1, cleanup=TRUE,...){ # save the old graphics settings-- they may be needed def.par <- par(no.readonly = TRUE) zones <- matrix(c(1,1,1, 0,5,0, 2,6,4, 0,3,0), ncol = 3, byrow = TRUE) layout(zones, widths=c(0.3,4,1), heights = c(1,3,10,.75)) # tuning to plot histograms nicely xhist <- hist(x, plot = FALSE) yhist <- hist(y, plot = FALSE) top <- max(c(xhist$counts, yhist$counts)) # for all three titles: # drop the axis titles and omit boxes, set up margins par(xaxt="n", yaxt="n",bty="n", mar = c(.3,2,.3,0) +.05) # fig 1 from the layout plot(x=1,y=1,type="n",ylim=c(-1,1), xlim=c(-1,1)) text(0,0,paste(plottitle), cex=2) # fig 2 plot(x=1,y=1,type="n",ylim=c(-1,1), xlim=c(-1,1)) text(0,0,paste(ylab), cex=1.5, srt=90) # fig 3 plot(x=1,y=1,type="n",ylim=c(-1,1), xlim=c(-1,1)) text(0,0,paste(xlab), cex=1.5) # fig 4, the first histogram, needs different margins # no margin on the left par(mar = c(2,0,1,1)) barplot(yhist$counts, axes = FALSE, xlim = c(0, top), space = 0, horiz = TRUE) # fig 5, other histogram needs no margin on the bottom par(mar = c(0,2,1,1)) barplot(xhist$counts, axes = FALSE, ylim = c(0, top), space = 0) # fig 6, finally, the scatterplot-- needs regular axes, different margins par(mar = c(2,2,.5,.5), xaxt="s", yaxt="s", bty="n") # this color allows traparency & overplotting-- useful if a lot of points plot(x, y , pch=19, col="#00000022", cex=xsize, ...) # reset the graphics, if desired if(cleanup) {par(def.par)} } scatterhist(rnorm(1000), rchisq(1000, 7)) 2013/12/15 Andre Oliveira <andreolsouza@yahoo.com.br> Já havia buscado em meus arquivos pessoais e na internet com construir este gráfico com uma rodada só de camandos. Algo deste tipo:
library("Simple") data(emissions) attach(emissions) simple.scatterplot(perCapita,CO2) title("GDP/capita vs. CO2 emissions 1999")
Só que não deu certo aqui, parece que esta biblioteca saiu dos repositórios.
Em Domingo, 15 de Dezembro de 2013 11:08, Rodrigo Coster <rcoster@gmail.com> escreveu:
Uma simples busca no google resulta em diversas soluções:
https://www.google.com/search?q=scatter+plot+with+histogram+r
O 2o link é mais amigável para quem não tem 'intimidade' com o ggplot2...
2013/12/15 Andre Oliveira <andreolsouza@yahoo.com.br>
Bom dia,
alguem da lsta sabe qual função do R faz este gráfico. https://www.dropbox.com/s/iyfef9sy4tfv4r4/teste.png
obrigado
_______________________________________________ R-br mailing list R-br@listas.c3sl.ufpr.br https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código mínimo reproduzível.