ggplot2 主题选项列表?

发布于 2024-08-21 14:41:50 字数 152 浏览 3 评论 0原文

经过一番研究,我找到了防止显示无信息图例的方法

... + theme(legend.position = "none")

在哪里可以找到 ggplot2 的所有可用 theme 选项及其默认值?

After some research I found the way to prevent an uninformative legend from displaying

... + theme(legend.position = "none")

Where can I find all of the available theme options and their default values for ggplot2?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

肩上的翅膀 2024-08-28 14:41:50

我能找到的最接近综合列表的是 ggplot2 wiki 在 github 上。我认为大多数选项都通过示例进行了介绍。

更新
如果您想查看当前绘图上使用的选项,可以使用plot_theme(x)来查看当前为名为 x 的绘图设置的所有选项。它不会是一个全面的列表,但如果您想更改轴标签的字体大小等内容,应该会有所帮助。

更新2
随着版本 0.9.0 的过渡,值得注意的是内置文档已得到显着改进,并且 从 0.8.9 到 0.9.0 的过渡指南也值得一看。

更新3
现在有一个 ggplot2 文档网站。查看主题的文档以获取完整列表。另外,从 0.9.3 开始,?theme 有一个相当完整的列表。

更新4
现在有一个 ggthemes 包,其中有一些不错的主题和比例可供选择。它可能会让您不必创建自己的。请参阅他们的 github 页面了解更多信息。

The closest thing to a comprehensive list that I have been able to find is in the ggplot2 wiki on github. I think that most of the options are covered there with examples.

Update
If you would like to see the options that are in use on a current plot, you can use plot_theme(x) to see all of the options that are currently set for the plot named x. It will not be a comprehensive list, but should help if you want to change something like the font size for an axis label.

Update 2
With the transition to version 0.9.0 it's worth noting that the built in documentation has been dramatically improved, and the transition guide from 0.8.9 to 0.9.0 is also worth checking out.

Update 3
There is now a ggplot2 documentation website. Look at the documentation for theme for a complete list. Also, ?theme has a pretty complete list as of 0.9.3.

Update 4
There is now a ggthemes package that has some nice themes and scales to choose from. It might save you from having to create your own. See their github page for more information.

萌面超妹 2024-08-28 14:41:50

输入后将

theme_get()

显示主题值和选项的完整列表。然后您可以按照语法在 opts() 中修改这些属性。

Entering in

theme_get()

will show a comprehensive listing of theme values and options. You can then follow the syntax to modify these attributes in opts().

策马西风 2024-08-28 14:41:50

ggplot2 包不包含太多参考信息——这可能是因为 Hadley 投入了大量的工作来开发和完善该包,创建了一个充满示例的网站,并编写了一本出色的书来描述系统详细。

我要寻找答案的第一个地方是 ggplot2 网站:

http://docs。 ggplot2.org/

然而,由于 opts() 并不是真正的几何、统计或比例,因此没有专门关注它的示例。下一个要查看的地方是网站上包含本书材料的部分 - 包括示例的源代码:

http ://ggplot2.org/book/

“完善你的绘图以供发布”一章的示例代码包含一些使用 set_theme()opts() 的评论良好的示例 改变绘图外观。

信息的最终来源当然是本书本身。如果您发现 ggplot2 简化了您生成统计图形的工作流程,那么购买本书是表达“谢谢”并支持该软件包进一步开发的好方法。

更新

经过进一步调查,您也许可以通过列出其中一个“主题”函数(例如theme_bw)的源代码来找到相对完整的选项列表。源代码没有提供可能的 key=value 对的描述,但它至少显示了通过 设置时有效的大多数 key 名称>opts()

The ggplot2 package does not contain much reference information-- this is probably because Hadley has put a lot of work into developing and polishing the package, creating a website full of examples and writing an excellent book that describes the system in detail.

The first place I would look for answers would be the ggplot2 website:

http://docs.ggplot2.org/

However, since opts() is not really a geom, stat or scale there are no examples that focus specifically on it. The next place to look would be the section of the website that contains material from the book-- including source code for examples:

http://ggplot2.org/book/

The example code for the chapter "Polishing your plots for publication" contains some well commented examples of using set_theme() and opts() to alter plot appearance.

The ultimate source for information is of course the book it's self. If you find ggplot2 has simplified and streamlined your workflow for producing statistical graphics, buying a copy of the book is a great way to say "thank you" and support the further development of the package.

Update

After some further investigation, you may be able to find a relatively complete list of options by listing out the source of one of the "theme" functions such as theme_bw. The source doesn't provide a description of the possible key=value pairs, but it does at least show most of the key names that have an effect when set via opts().

予囚 2024-08-28 14:41:50

除了明显引用 ggplot2 参考手册Cookbook for R 的图表部分,Hadley Wickham 在 github

Besides the obvious references to ggplot2 reference manual and to the graphs section of Cookbook for R, Hadley Wickham provides a nice opts() List on github.

故事灯 2024-08-28 14:41:50

主题模板:

https://github.com/jrnold/ggthemes

就像“ 《经济学家》、《Stata》、《tufte》等等……

我知道答案并不完全是所问的,但这正是我发现这个问题时所寻找的,所以其他人也可能如此。

Theme templates:

https://github.com/jrnold/ggthemes

like "The economist", "Stata", "tufte" and more..

I know the answer is not exactly what was asked, but it was what I was looking for when I found this question, so others might too.

我不是你的备胎 2024-08-28 14:41:50

我曾经使用过的所有选项都在 hadley 的伟大的 ggplot2 书中进行了解释。

All the options I've ever used have been explained in hadley's great ggplot2 book.

梦纸 2024-08-28 14:41:50

我找到的 0.9.2.1 版本的最佳列表位于此处

Best list I've found for version 0.9.2.1 is here.

坐在坟头思考人生 2024-08-28 14:41:50

?选择
虽然,这没有显示如何微调其参数,因此最好检查上面给出的选项。如果您可以获得 ggplot2 参考手册的副本,它将对您有很大帮助。

?opts
although, this does not display how to finetune its arguments, therefore it's better to check the options given above. If you can get a copy of the ggplot2 reference manual, it will help you a lot.

不再见 2024-08-28 14:41:50

我为您可能寻找的任何主题或任务做了这个快速参考。为了更全面地理解,这个 ggplot2 教程应该会有所帮助。

I made this quick reference for any theme or tasks you might look for. For a more general understanding, this ggplot2 tutorial should help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文