我想為我正在成長Lollipop chart
的特定包裝貼紙繪制一個。r
我想要這樣,不legend
,不x-axis
,不,y-axis
我想要的只是一個簡單的情節。
我有的
df1 <- read.table(text =
"nbb_RMSE 9 0.2402482
mbb_RMSE 9 0.1023012
cbb_RMSE 8 0.2031448
tmbb_RMSE 4 0.2654746
tcbb_RMSE 9 0.4048711")
colnames(df1) <- c("Methods", "lb", "RMSE")
df1 |>
dplyr::mutate(colour = fct_reorder(Methods, RMSE)) |>
ggplot2::ggplot(aes(Methods, RMSE, colour = colour))
ggplot2::geom_point(size = 4)
ggplot2::geom_segment(aes(Methods, xend = Methods, yend = RMSE, y = 0))
ggplot2::scale_color_manual(values = c("green", "yellowgreen", "yellow",
"orange", "red"),
labels = c(9, 8, 9, 9, 4), name = "lb")
ggplot2::theme_bw(base_size = 16)
這是
我想要的是
我想
uj5u.com熱心網友回復:
您可以element_blank()
為不需要的元素設定theme
.
library(tidyverse)
library(forcats)
df1 <- read.table(text =
"nbb_RMSE 9 0.2402482
mbb_RMSE 9 0.1023012
cbb_RMSE 8 0.2031448
tmbb_RMSE 4 0.2654746
tcbb_RMSE 9 0.4048711")
colnames(df1) <- c("Methods", "lb", "RMSE")
df1 |>
dplyr::mutate(colour = fct_reorder(Methods, RMSE)) |>
ggplot2::ggplot(aes(Methods, RMSE, colour = colour))
ggplot2::geom_point(size = 4)
ggplot2::geom_segment(aes(Methods, xend = Methods, yend = RMSE, y = 0))
ggplot2::scale_color_manual(values = c("green", "yellowgreen", "yellow",
"orange", "red"),
labels = c(9, 8, 9, 9, 4), name = "lb")
ggplot2::theme_bw(base_size = 16)
theme(panel.border = element_blank(),
legend.position = "none",
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank())
由reprex 包(v2.0.1)于 2022-06-04 創建
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/485865.html
上一篇:在R中繪制條形圖
下一篇:在一個繪圖中可視化多個資料框列