How to adjust the height of a tile in a geometric slab?

I am trying to make a plot with ggplot2, but I am struggling with geotag. Since I am using this geometry for the first time, I carefully looked at the Hadley documentation, but so far I have not been able to get what I am behind it. I want to adjust the width of the tile and the height of the tile. I found how to adjust the tile width in the documentation, but I am struggling with height. The following chart should be used as a starting point:

test <- data.frame(
  x = rep(c(1,3,6),2),
  y = rep(c(1,3), each = 3),
  w = rep(c(.5,2,1), 2),
  z = sample(rep(LETTERS[1:6])))

ggplot(test, aes(x=x, y=y, fill = z)) + geom_tile(aes(width = w))

enter image description here

. "" ( x = 1) 0 1, 1 4. 0 3 3 4. , 0 1,5 1,5 4. , :

test2 <- data.frame(
 x = rep(c(1,3,6),2),
 y = c(0, 0, 0, 1, 3, 1.5),
 w = rep(c(.5,2,1), 2),
 z = sample(rep(LETTERS[1:6])),
 h = c(1, 3, 1.5, 3, 1, 2.5))

ggplot(test2, aes(x=x, y=y, fill = z)) + geom_tile(aes(width = w, heigth = h))

, .

. !

+5
2

geom_tile height=h ymin ymax -h/2 to h/2. , . @Didzis, , geom_tile . :).

, "" y , , . test2 data.frame,

require(plyr)
# calculate y coordinate accounting for shift in y due to h
test2 <- ddply(test2, .(x), transform, y2 = c(0, head(h,-1)) + h/2)
p <- ggplot(test2, aes(x=x, y=y2, fill = z)) + 
           geom_tile(aes(width = w, height=h))
p

enter image description here

, (ymin ymax)

ggplot_build(p)$data

#      fill x    y PANEL group xmin xmax ymin ymax
# 1 #00BFC4 1 0.50     1     4 0.75 1.25  0.0  1.0
# 2 #619CFF 1 2.50     1     5 0.75 1.25  1.0  4.0
# 3 #00BA38 3 1.50     1     3 2.00 4.00  0.0  3.0
# 4 #F8766D 3 3.50     1     1 2.00 4.00  3.0  4.0
# 5 #B79F00 6 0.75     1     2 5.50 6.50  0.0  1.5
# 6 #F564E3 6 2.75     1     6 5.50 6.50  1.5  4.0
+7

geom_tile() geom_bar() stat="identity" h y. width= geom_bar(), , .

ggplot(test2,aes(x,h,fill=z))+geom_bar(stat="identity",aes(width=w))

enter image description here

+5

All Articles