I want to plot a Lollipop chart
for a particular r
package sticker that I am growing. I want it such that no legend
, no x-axis
, no y-axis
all I want is just a plain plot.
What I have
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)
What I Want
I want
CodePudding user response:
You can set element_blank()
for the elements that you don't want in 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())
Created on 2022-06-04 by the reprex package (v2.0.1)