Reputation: 35
I need to show only the elements of the y axis and nothing else.
name <- c("A", "B", "C", "D", "E")
values <- c(1, 2, 3, 4, 5)
data<-data.frame(name, values)
ggplot()
geom_blank(data=data, aes(y=reorder(name,desc(name))))+
theme(axis.text.x=element_blank(),
axis.title = element_blank(),
axis.text.y=element_text(colour="black"))
This still shows the plot. I want to show only the y axis elements.
Upvotes: 1
Views: 246
Reputation: 12739
Is this what you are looking for?
name <- c("A", "B", "C", "D", "E")
values <- c(1, 2, 3, 4, 5)
df1<-data.frame(name, values)
library(ggplot2)
library(dplyr)
ggplot(df1, aes(values, y=reorder(name,desc(name)))) +
theme_void()+
theme(axis.text.y=element_text(colour="black"))
Created on 2023-02-09 with reprex v2.0.2
Upvotes: 0
Reputation: 23807
If your aim is just to draw five letters without anything else, no need to bother with axes, but draw the labels directly.
ggplot() +
annotate(geom = "text", x = 1, y = 1:5, label = rev(LETTERS[1:5])) +
theme_void()
Upvotes: 1
Reputation: 274
This will get you most of the way there:
ggplot()+
geom_blank(data=data, aes(y=reorder(name,desc(name))))+
theme_minimal()
Then you just need to drop the gridlines and label:
ggplot()+
geom_blank(data=data, aes(y=reorder(name,desc(name))))+
theme_minimal()+
theme(panel.grid = element_blank(),
axis.title = element_blank())
Upvotes: 0