Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Positioning of layer_text with layer_rects #243

Open
kevinykuo opened this issue Aug 19, 2014 · 1 comment
Open

Positioning of layer_text with layer_rects #243

kevinykuo opened this issue Aug 19, 2014 · 1 comment
Milestone

Comments

@kevinykuo
Copy link

See http://stackoverflow.com/questions/24701419/heat-map-with-numbers-in-ggvis

Is this hard to fix?

@wch
Copy link
Contributor

wch commented Sep 30, 2014

You can work around it by adding xcenter and ycenter scales:

hec <- as.data.frame(xtabs(Freq ~ Hair + Eye, HairEyeColor))

hec%>%
  ggvis(~Hair, ~Eye, fill=~Freq) %>%
  layer_rects(width = band(), height = band()) %>%
  layer_text(
    x = prop("x", ~Hair, scale = "xcenter"),
    y = prop("y", ~Eye, scale = "ycenter"),
    text:=~Freq, fontSize := 20, fill:="white", baseline:="middle", align:="center") %>%
  scale_nominal("x", padding = 0, points = FALSE) %>%
  scale_nominal("y", padding = 0, points = FALSE) %>% 
  scale_nominal("x", name = "xcenter", padding = 1, points = TRUE) %>%
  scale_nominal("y", name = "ycenter", padding = 1, points = TRUE)

In general we should have better ways of mixing centered and non-centered x/y scales. This is related to #242.

@hadley hadley added this to the 0.5 milestone Oct 6, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants