ggplot2 - 摆脱ggplot中面板上的边框?
问题描述
我正在尝试删除此数据的边界,即。这是我当前的代码:
ggplot(data = GDP, aes(x=year, y=gdp_percap/1e3, fill=continent)) +
geom_col() +
facet_wrap(~continent, ncol=2) +
ylab("GDP") +
theme_minimal() +
theme(legend.position = "none",
panel.background = element_rect(fill=NA, color="gray50"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank())
strip.background = element_rect(fill=NA, color=NA) +
scale_y_continuous(expand = expand_scale(mult = c(0, 0.05)),
breaks = seq(0,200,100),limits=c(0,NA)) +
scale_x_continuous(expand = c(0,0),
breaks = seq(1950,2000,20))
解决方案
我相信边界是指所有方面的框?在这种情况下,请注意您指定让每个构面都有一个透明的背景矩形,其中包含:panel.background = element_rect(fill=NA, color="gray50")
。
将其更改为此,您将删除所有这些边框:
panel.background = element_blank()
如果您仍然需要轴线(只要您有轴标签,则为 X 和 Y),请在以下内容中添加theme(...)
:
axis.line = element_line(color='black')
有关格式化的更多信息,此资源非常有用。
推荐阅读
- python - 为什么我得到 NoneType?
- oracle - 当状态处于活动状态时,如何制作一个 PL/SQL 程序来更新学生费用?
- react-native - CORS 策略已阻止从源“myLocalHost”获取“myUrl”的访问权限
- javascript - 自动化谷歌日历访问授权代码检索 - NodeJS
- python - Google Colab 停止运行我的代码的单元格
- python - 列在数据框中可用,但在切片数据框时未获取
- reactjs - 为反应中的单个项目分配多个路线
- css - react bootstrap 如何在较小的屏幕上将列转换为行?
- c# - 在 Pester 中完成测试的 ASP.NET 核心应用程序的代码覆盖率
- powershell - 使用 adsisearcher 在域中查找计算机名称(如果存在或不存在)并将值返回给 result = true