网格线和背景的颜色
看来这个问题首先出现< /a> 大约在 2007 年。
问题是这样的:
在 R 中使用 ggplot2 绘图时如何更改网格线和背景颜色?我添加两张图片作为背景和网格线颜色含义的示例。
早在 2007 年,Hadley Wickham 就表示缺少外观功能(包括更改背景颜色)。有谁知道是否有允许更改背景颜色和网格线颜色的更新?
提前致谢
It seems that this question first appeared around 2007.
The question is this:
How to change the gridline and background color when plotting with ggplot2 in R? I add two pictures as an example of what I mean by background and gridline color.
Back in 2007, Hadley Wickham said that appearance functionalities were missing (this included changing the color of the background). Does anybody know if there's an update that allows changing the background color and the color of the gridlines?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
注意:从0.9.2版本开始,这是使用完成的
theme
:此外,还有
panel.grid.major
和panel.grid.minor
选项。有关选项的完整列表和一些示例,请参阅此处。?theme
处也有文档。在旧版本的ggplot2中,这是通过以下方式完成的:
您还可以使用
theme_bw()
切换到更传统的主题。您还可以在 this SO 线程上找到有关主题和 opts() 的信息。
Note: Since version 0.9.2 this is done using
theme
:Additionally, there are
panel.grid.major
andpanel.grid.minor
options. See here for a full list of options and some examples. There is also documentation at?theme
.In older version of ggplot2 this was done via:
You can also switch to more traditional theme using
theme_bw()
.You can also find information on themes and opts() on this SO thread.
我发现一个有点隐藏的选项有助于识别这些东西的“位置”以及它们的名称:
它向您显示所有主题选项的调用和定义。另外,如果您打算搞乱主题,您应该记住,您可以将许多调用保存为列表对象...例如:
当我自定义主题以匹配时,我经常使用它企业风格或类似的东西。
A somewhat hidden option that I find helpful for identifying "where" these things are and what they are called is:
It shows you both the call and the definitions for all of the theme options. Also, if you're going to be messing about with thematics, you should keep in mind that you can save a number of calls as a list object... for example:
I use this a lot when I'm customizing themes to match a corporate style or something of that like.