【发布时间】:2011-12-03 08:29:21
【问题描述】:
我还在学习Sweave 和R。我在下面有一个示例代码,它读取数据文件并绘制它。我选择postscript 选项,因为我喜欢以EPS 文件结尾。我想通过情节改进很多事情。这是我的代码和我自己的 cmets 供我自己学习:
\documentclass[a4paper,12pt]{article}
\usepackage{Sweave} %%%%%%
\SweaveOpts{eps=TRUE}
\begin{document}
<<echo=FALSE, results=hide>>=
test.frame<-data.frame(ratio= c(0.0, 144.321, 159.407, 178.413, 202.557), value= c(0, 0.84, 0.8925, 0.945, 0.9975))
@
<<echo=FALSE,results=hide,eval=TRUE>>=
postscript('doudou.eps',
width=7, height=6,
colormodel="cmyk",
family = "ComputerModern",
horizontal = FALSE,
onefile=FALSE,
paper = "special",
encoding = "TeXtext.enc",
pagecentre=FALSE)
with(test.frame,plot(ratio, value, ylab= "Hello",
xlab="Wonderful",
type="o", # line and markers
bty="o", # box around graph
lty="solid", # solid line or put 1
lwd=3, # line width
pch=1, # or enclose symbol in quotes
cex=3, # size of markers
cex.lab=2, # label size
cex.axis=1.5, # axis annot size problem if big
cex.main=2, # main title size
xaxp=c(0, 200, 4), #c(x1, x2, n)
col=2, # plotting color
xlim=c(0,200),
yaxt = "n", #suppresses axis
main=" My curve"))
axis(2,seq(0,1, by=0.5), las=2,cex=3,cex.lab=2,cex.axis=1.5,cex.main=2)
dev.off()
@
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.8\textwidth]{doudou.eps}
\end{center}
\end{figure}
\end{document}
我想了解更多关于改进的一些事情:
我在情节周围有一个框框。如何控制它的线宽?
我使用
cex.axis=1.5作为轴注释大小。如果我将其更改为cex.axis=3,那么 x 轴上的值会变大并且它们与刻度线重叠。有没有办法让 x 轴值离绘图更远一点?y 标签
Hello在图中H字母的顶部被截断。如何解决这个问题?如何将 x-label
Wonderful或 y-labelHello移离绘图更远?如果我们查看绘制的曲线,虽然数据集的初始值为 (0,0),但轴并非从 (0,0) 开始。如何控制坐标轴使其从 (0,0) 开始?
非常感谢...
【问题讨论】:
-
据我所知,您的任何问题都与 SWeave 无关。由于将示例代码加载到 SWeave 中比仅 R 更麻烦,因此请通过删除所有 SWeave 内容来编辑您的问题。那我去看看。
-
@Andrie 我将来会尝试将我的 R 和 Sweave 查询分开。现在我已经得到了这篇文章的答案。