如何删除 R 中已经存在于图例中的条形图上方的标签?
How to delete label above bar chart in R that's already in the legend?
这是我的第一个 post!
只是想知道如何删除图表上方的这些标题:
这是图表的代码!
我想我必须使用类似的东西:
p + 主题(axis.title.x = element_blank(), axis.title.y = element_blank())
ggplot(data=bike_data_v4)+
geom_bar(mapping = aes(x=day_of_week,fill=member_casual))+
scale_x_discrete(limits = c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),
labels = c("Sun","Mon","Tue","Wed","Thu","Fri","Sat"))+ #the discrete lines show how I rearranges the x-axis labels to go from sun-sat and be renamed to shorter text
facet_wrap(~member_casual)+
labs(title="Weekly Rider Differences by Cyclist Type", subtitle="Members vs. Casual Riders",
x = "Day of the Week",
y = "Number of Overall Rides",
caption="Data Provided by Google Capstone Project")+
scale_y_continuous(limits=c(0,500000), labels = scales::comma)+ #this combined scale_y_continuous(limits=c(0,500000) AND scale_y_continuous(labels=comma)
theme_fivethirtyeight()+
labs(fill='Rider Type')+
theme(axis.title = element_text())
您正在寻找 strip.text
选项。
library(tidyverse)
iris |>
ggplot(aes(x = Sepal.Length, y = Petal.Length)) +
geom_point() +
facet_wrap(~ Species) +
theme(strip.text = element_blank())
最后我改了最底层的代码!添加 strip.text = element_blank())
现在条形图如下所示:
ggplot(data=bike_data_v4)+
geom_bar(mapping = aes(x=day_of_week,fill=member_casual))+
scale_x_discrete(limits = c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),
labels = c("Sun","Mon","Tue","Wed","Thu","Fri","Sat"))+ #the discrete lines show how I rearranges the x-axis labels to go from sun-sat and be renamed to shorter text
facet_wrap(~member_casual)+
theme(strip.text = element_blank())+
labs(title="Weekly Rider Differences by Cyclist Type", subtitle="Members vs. Casual Riders",
x = "Day of the Week",
y = "Number of Overall Rides",
caption="Data Provided by Google Capstone Project")+
scale_y_continuous(limits=c(0,500000), labels = scales::comma)+ #this combined scale_y_continuous(limits=c(0,500000) AND scale_y_continuous(labels=comma)
theme_fivethirtyeight(base_size = 12, base_family = "sans")+
labs(fill='Rider Type')+
theme(axis.title = element_text(), strip.text = element_blank())
这是我的第一个 post!
只是想知道如何删除图表上方的这些标题:
这是图表的代码!
我想我必须使用类似的东西:
p + 主题(axis.title.x = element_blank(), axis.title.y = element_blank())
ggplot(data=bike_data_v4)+
geom_bar(mapping = aes(x=day_of_week,fill=member_casual))+
scale_x_discrete(limits = c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),
labels = c("Sun","Mon","Tue","Wed","Thu","Fri","Sat"))+ #the discrete lines show how I rearranges the x-axis labels to go from sun-sat and be renamed to shorter text
facet_wrap(~member_casual)+
labs(title="Weekly Rider Differences by Cyclist Type", subtitle="Members vs. Casual Riders",
x = "Day of the Week",
y = "Number of Overall Rides",
caption="Data Provided by Google Capstone Project")+
scale_y_continuous(limits=c(0,500000), labels = scales::comma)+ #this combined scale_y_continuous(limits=c(0,500000) AND scale_y_continuous(labels=comma)
theme_fivethirtyeight()+
labs(fill='Rider Type')+
theme(axis.title = element_text())
您正在寻找 strip.text
选项。
library(tidyverse)
iris |>
ggplot(aes(x = Sepal.Length, y = Petal.Length)) +
geom_point() +
facet_wrap(~ Species) +
theme(strip.text = element_blank())
最后我改了最底层的代码!添加 strip.text = element_blank())
现在条形图如下所示:
ggplot(data=bike_data_v4)+
geom_bar(mapping = aes(x=day_of_week,fill=member_casual))+
scale_x_discrete(limits = c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),
labels = c("Sun","Mon","Tue","Wed","Thu","Fri","Sat"))+ #the discrete lines show how I rearranges the x-axis labels to go from sun-sat and be renamed to shorter text
facet_wrap(~member_casual)+
theme(strip.text = element_blank())+
labs(title="Weekly Rider Differences by Cyclist Type", subtitle="Members vs. Casual Riders",
x = "Day of the Week",
y = "Number of Overall Rides",
caption="Data Provided by Google Capstone Project")+
scale_y_continuous(limits=c(0,500000), labels = scales::comma)+ #this combined scale_y_continuous(limits=c(0,500000) AND scale_y_continuous(labels=comma)
theme_fivethirtyeight(base_size = 12, base_family = "sans")+
labs(fill='Rider Type')+
theme(axis.title = element_text(), strip.text = element_blank())