你好,我在 R 中的 knitr 中有這個圖,我想將其傳輸到我的 Latex PDF 文件中,但它太大了,填滿了頁面的 3/4:
compPlot ( mdata$GDP, fitted( cesNewton), xlab = "Real Values",
ylab = "Fitted Values", col="red", main="Newton Method",
cex.main=1, cex.lab=0.75, cex.axis=0.75)
我怎麼能讓它變小並居中在頁面中間?
\documentclass{article}
\begin{document}
<<>>=
library(micEconCES)
library(readxl)
DATA_FOR_2 <- read_excel("~/Documents/DATA FOR 2.xlsx",
col_types = c("text", "text", "text", "text", "text",
"numeric", "numeric","numeric", "numeric", "numeric",
"numeric", "numeric", "numeric", "numeric", "numeric",
"numeric", "numeric", "numeric", "numeric", "numeric",
"numeric"))
mdata <- DATA_FOR_2[-c(46:62), ]
cesKmenta <- cesEst( yName = "GDP", xNames = c( "Capital", "Labour" ),
data = mdata, method = "Kmenta", vrs = TRUE )
library( "miscTools" )
compPlot ( mdata$GDP, fitted( cesKmenta ), xlab = "Real Values",
ylab = "Fitted Values", col="red", main="Newton Method",
cex.main=1, cex.lab=0.75, cex.axis=0.75)
@
\end{document}
抱歉,我不知道如何新增可重現的數據,我只是列出了我匯入的 Excel 工作表
答案1
您必須使用 chunk 選項來控制輸出,並閱讀這個重要頁面:https://yihui.name/knitr/options/
這是一個可以回答您問題的 MRE
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
\begin{figure}
\centering
<<minimal, fig=TRUE, height=12>>=
data(mtcars)
plot(mtcars[,1:2])
@
\end{figure}
\end{document}