改变轴方向
Change axis direction
如何在 ggvis 图中改变轴方向?
例如,y 轴。我希望原点位于图表的左上方(我已经通过放置 orient ="top" 将我的 x 轴放在顶部)。
data %>%
ggvis(~XX, ~YY) %>%
layer_points() %>%
add_axis("y", title = "Y title") %>%
add_axis("x", title = "X title", orient ="top")
我相信您需要 scale_numeric
参数和 reverse = TRUE
来翻转范围的顺序。
下面是一个基于 mtcars
数据集的示例。
library(ggvis)
mtcars %>% ggvis(~wt, ~mpg) %>%
layer_points() %>%
add_axis("x", orient = "top") %>%
scale_numeric("y", reverse = TRUE)
如何在 ggvis 图中改变轴方向?
例如,y 轴。我希望原点位于图表的左上方(我已经通过放置 orient ="top" 将我的 x 轴放在顶部)。
data %>%
ggvis(~XX, ~YY) %>%
layer_points() %>%
add_axis("y", title = "Y title") %>%
add_axis("x", title = "X title", orient ="top")
我相信您需要 scale_numeric
参数和 reverse = TRUE
来翻转范围的顺序。
下面是一个基于 mtcars
数据集的示例。
library(ggvis)
mtcars %>% ggvis(~wt, ~mpg) %>%
layer_points() %>%
add_axis("x", orient = "top") %>%
scale_numeric("y", reverse = TRUE)