- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试解决我拥有的 otf 字体问题(请参阅 How to use otf-font in ggplot2 graphics? ),我发现我可以在 ggplot2 中使用这些字体。
将knitr与Rmd文件一起使用是可以的:
---
title: "FontTest"
author: "me"
date: "22. April 2015"
output: html_document
---
```{r, echo=FALSE}
library(ggplot2)
ggplot(mtcars, aes(x=wt, y=mpg, color=factor(gear))) + geom_point() +
ggtitle("Fuel Efficiency of 32 Cars") +
xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
theme(text=element_text(size=16, family="Arial"))
```
但是当我想使用 LaTeX(Rnw 文件)时,我收到错误:
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<>>=
Sys.setenv(LANG = "en")
library(ggplot2, quietly=TRUE)
@
<<>>=
ggplot(mtcars, aes(x=wt, y=mpg, color=factor(gear))) + geom_point() +
ggtitle("Fuel Efficiency of 32 Cars") +
xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
theme(text=element_text(size=16, family="Arial"))
@
\end{document}
错误如下:
Writing to file test.tex
Processing code chunks with options ...
1 : echo keep.source term verbatim (test.Rnw:6)
2 : echo keep.source term verbatim (test.Rnw:13)
Error in grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y, :
invalid font type
Calls: <Anonymous> ... drawDetails -> drawDetails.text -> grid.Call.graphics
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted
我使用的是 Mac OS X Mavericks。
更新
我找到了使用开罗的解决方法:
\documentclass{article}
\begin{document}
<<>>=
Sys.setenv(LANG = "en")
library(ggplot2, quietly=TRUE)
library(Cairo)
@
<<dev='cairo_pdf'>>=
ggplot(mtcars, aes(x=wt, y=mpg, color=factor(gear))) + geom_point() +
ggtitle("Fuel Efficiency of 32 Cars") +
xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
theme(text=element_text(size=16, family="Source Code Pro"))
@
\end{document}
但现在我收到很多警告:
## Warning in grid.Call(LtextBounds, as.graphicsAnnot(x$label), x$x,x$y, : font family 'Source Code Pro' not found in PostScript fontdatabase
我想避免抑制这些警告。那么我该怎么做才能消除这些警告呢?
最佳答案
我找到了以下解决方案:
我用
\usepackage{tikz}
和
<<plot, dev='tikz'>>
在我的 .Rnw 文件中。通过这种方式,我可以在绘图中获得 LaTeX 项目的字体。
关于r - knitr、开罗和 ggplot2 : font family 'Source Code Pro' not found in PostScript fontdatabase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29803524/
我有 future PNG字符的宽度和高度,需要绘制精确适合的图片。 int font_height=13, font_width=?; cairo_surface_t *surface = cai
在 Raspberry Pi 上使用 C++ 下的 Cairo,并尝试将文本绘图剪切到给定矩形内。 我原以为它会像这样简单: cairo_t* cp = cairo_create(psurface);
我必须创建一个跨平台(Windows、OS X、Linux)的 OpenGL 应用程序,我一直在寻找一个好的 2D 图形库,没有很多花哨的东西(所以 SDL、QT、Juce 不在我的工作范围之内) .
我是 python3 的新手。我已经创建了虚拟环境。我尝试使用 pip 命令安装 pycairo 包。我需要安装 python cairo。请看下面的信息 pip install git+http:/
我正在手动编译 GTK+,因为它需要开罗支持 pdf,我安装了 poppler-glib,但即使在开罗的配置脚本中我也得到: checking for cairo's PDF surface back
假设我在窗口中创建一个空白区域并在其中绘制一些线条,我如何将其保存为 .png 或 .jpg?或者可能将其转换为 PIL 可以理解的对象? 最佳答案 在这里回答:Using Pycairo to ge
我正在开发一个用 Cairo + Gtk 编写的应用程序。请注意,由于逆向兼容性问题,我不得不使用 Python 作为编程语言,使用 PyGTK 作为包装器,并使用 GTK 库 v.2.24。没有机会
假设我制作了一个这样的表面: cairo_surface_t* surface = cairo_pdf_surface_create("pdffile.pdf", 40000, 40000); cai
我正在使用 cairo 绘制一些圆弧,这是函数。 cairo_t* drawCircle(cairo_surface_t *container, int x, int y, int r, int cr
我在 Windows 上使用 ghci+cairo 时遇到问题。当我尝试加载时,例如像这样的“ghci -package cairo”,它失败并出现以下错误: Loading package rand
我的目的(用于个人练习)是创建一个平面笛卡尔,其中我代表一些数学函数。因此我需要交易坐标,如何在 DrawArea 上添加文本?我搜索过,但没有找到任何关于使用 gtk3-C 绘制文本的内容(示例 e
我有一个多线程应用程序,其中每个线程都创建自己的表面、渲染内容、保存并销毁所有内容。 但是,一段时间后(例如保存了 20 张图像),应用程序卡在 cairo-atomic-private.h 的 _c
我想在 GTK 窗口中显示原始 RGB 图像流(固定大小,没有 alpha channel ,window); cairo_set_source_surface(cr, image, 10,
Pango 语法支持一些纯文本标记。据我所知,这也没有扩展到嵌入图像。 环顾四周,我找不到太多现有实现方式,但我之前没有做过 pango+cairo 工作,所以我可能会错过明显的社区。 据我所知,一个
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 Improve th
我正在尝试在 ARM Linux 平台上通过用 C 语言编写的 OpenGL ES 2.0 应用程序渲染 HUD。 我目前正在使用靠近近裁剪平面放置的 2 个三角形,并将纹理平铺到它们上面。纹理是屏幕
我正在尝试安装 GTK-DFB,并且需要 cairo。当我尝试从源代码构建它时,它会抛出: checking for cairo's PNG functions feature... configur
这是我现在使用的代码: surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, *image.size) context = cairo.Context(s
我很笨 :) 那么有人可以帮忙编写分步手册,如何安装“cairo”、“glut”并在 Windows 7 上的 VS 2010 项目 (C++) 中使用它吗? PS:最有趣的事情是我在 Linux 中
我想使用 Java 创建 pdf、svg 和高分辨率抗锯齿 img。 java-gnome 项目 (http://java-gnome.sourceforge.net/4.0/) 包含 cairo绑定
我是一名优秀的程序员,十分优秀!