我正在使用knitr
,ggplot
。我想要一个这样的情节: 显示更好。但我仍然得到这样的: ggplot2中的变化率
\begin{landscape}
<< mygrah2>>=
require(ggplot2)
ggplot(T2,aes(x=age,y=value,fill=Position))
+geom_boxplot()+ggtitle("Distribuition of frequencies per age in 3
collected positions.\n N=1000,K=10,T=2")+theme(legend.position="bottom")
@
\end{landscape}
我已经尽量选择out.width
,fig.width
但不工作。
编辑:
我确定我正在使用knitr。我在下面做了一个例子。作为@Thierry,令人难过的解决方案是一起使用fig.height和fig.width。非常感谢。
\documentclass[letterpaper,12pt]{article}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{color}
\usepackage{placeins}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{lscape}
\usepackage{fullpage}
\usepackage{pdflscape}
\begin{document}
<<readdata>>=
data(mtcars)
mtcars$gear <- factor(mtcars$gear,levels=c(3,4,5),
labels=c("3gears","4gears","5gears"))
mtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8),
labels=c("4cyl","6cyl","8cyl"))
require(ggplot2)
@
\begin{landscape}
<<migraph>>=
#normal plot
ggplot(mtcars,aes(x=gear,y=mpg,fill=gear))+geom_boxplot()
@
<<migraph2,fig.width=10>>=
# weird
ggplot(mtcars,aes(x=gear,y=mpg,fill=gear))+geom_boxplot()
@
<<migraph3,fig.height=2,fig.width=10>>=
# It is what I looking for
ggplot(mtcars,aes(x=gear,y=mpg,fill=gear))+geom_boxplot()
@
<<migraph4,out.height="2in",out.width="10in">>=
# weird
ggplot(mtcars,aes(x=gear,y=mpg,fill=gear))+geom_boxplot()
@
\end{landscape}
\end{document}
设置fig.width和fit.height应该工作。如果没有,然后发布一个可重复的例子 – Thierry
[如何使一个伟大的R可重现的例子?](http://stackoverflow.com/questions/5963269) – zx8754
你确定你正在使用knitr吗?您可以检查您是否使用Sweave - >工具 - >全局选项 - > Sewave - >使用 - 编织Rnw文件 - >检查您是否有knitr或Sweave?如果你想使用knitr块选项,你应该换成knitr –