将 LaTeX 引入 R 图中 [英] Getting LaTeX into R Plots

查看:40
本文介绍了将 LaTeX 引入 R 图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 LaTeX 排版添加到 R 中的绘图元素(例如:标题、轴标签、注释等)使用 <的组合code>base/lattice 或使用 ggplot2.

问题:

  • 有没有办法使用这些包将 LaTeX 放入绘图中,如果有,它是如何完成的?
  • 如果没有,是否需要其他软件包来完成此操作.

例如,在 Python matplotlib 中,通过 text.usetex 包编译 LaTeX,如下所述:

I would like to add LaTeX typesetting to elements of plots in R (e.g: the title, axis labels, annotations, etc.) using either the combination of base/lattice or with ggplot2.

Questions:

  • Is there a way to get LaTeX into plots using these packages, and if so, how is it done?
  • If not, are there additional packages needed to accomplish this.

For example, in Python matplotlib compiles LaTeX via the text.usetex packages as discussed here: http://www.scipy.org/Cookbook/Matplotlib/UsingTex

Is there a similar process by which such plots can be generated in R?

解决方案

Here's an example using ggplot2:

q <- qplot(cty, hwy, data = mpg, colour = displ)
q + xlab(expression(beta +frac(miles, gallon)))

这篇关于将 LaTeX 引入 R 图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆