Weiß jemand, wie man einen Farbbalken in ggvis
oder ggplot2
ohne irgendwelche Ränder bildet? ggvis
ist bevorzugt, da ich dies in eine shiny
Anwendung setze.ggvis colorbar (oder ggplot2) ohne Rand
Ich habe ein teilweise Arbeitsbeispiel in ggplot2:
Daten:
legendData <- c(100, 325, 550, 775, 1000)
legendColors <- c("#FF9DEB", "#9FC5FF", "#00E4D0", "#AAD44D", "#FFAE85")
df <- data.frame(x = legendData, col = legendColors, y = 1:5, stringsAsFactors = FALSE)
theme_nothing() stammt aus ggmap
und die Funktion von here kopieren.
ggplot2 (hat Ränder):
ggplot(df, aes(y = 1, x = x, fill = col)) + geom_tile() +
scale_fill_identity() + theme_nothing()
das Lauf gibt mir diese image. Leider hat das immer noch Margen.
Ich habe einige ggvis
Code, aber es funktioniert nicht mehr. Es gibt mir den Fehler "Waagen müssen zählbar oder nicht zählbar sein".
ggvis (nicht funktioniert):
df %>% ggvis(~y, ~x, fill := ~col) %>%
layer_rects(width = band(), height = band()) %>%
scale_nominal("x", padding = 0, points = FALSE) %>%
scale_nominal("y", padding = 0, points = FALSE) %>%
add_axis("y", title = "", properties = axis_props(labels = list(fontSize = 14))) %>%
add_axis("x", title = "") %>% set_options(width = 25, height = 100)
Dank.
Ihre 'ggvis' Code ausgeführt wird, wenn Sie Faktoren/Zeichen für 'X' verwenden und' anstelle von ganzen Zahlen y'. – aosmith