假设我有一个简单的情节:
mu = matrix(c(0,0),2,1)
sigma = matrix(c(1,0,0,1),2,2)
x = mvrnorm(1000, mu, sigma)
plot(x,pch=20,panel.first = grid(10, lty = 2, lwd = 2))
如何将此图表导出到 .tex 文件格式?我的意思是直接输出到 tex ,我不想使用TIKZ。
以下是如何在gnuplot中执行此操作
set terminal latex
set output "eg2.tex"
set size 5/5., 4/3.
set format xy "$%g$"
set title ’This is a plot of $y=\sin(x)$’
set xlabel ’This is the $x$ axis’
set ylabel ’This is\\the\\$y$ axis’
plot [0:6.28] [0:1] sin(x)
然后您将tex文件包含在tex文档中。
我可能犯了一个错误,但gnuplot的上述内容如下:
% GNUPLOT: LaTeX picture
\setlength{\unitlength}{0.240900pt}
\ifx\plotpoint\undefined\newsavebox{\plotpoint}\fi
\sbox{\plotpoint}{\rule[-0.200pt]{0.400pt}{0.400pt}}%
\begin{picture}(1500,900)(0,0)
\sbox{\plotpoint}{\rule[-0.200pt]{0.400pt}{0.400pt}}%
\put(110.0,82.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(90,82){\makebox(0,0)[r]{$0$}}
\put(1419.0,82.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(110.0,237.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(90,237){\makebox(0,0)[r]{$0.2$}}
\put(1419.0,237.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(110.0,393.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(90,393){\makebox(0,0)[r]{$0.4$}}
\put(1419.0,393.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(110.0,548.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(90,548){\makebox(0,0)[r]{$0.6$}}
\put(1419.0,548.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(110.0,704.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(90,704){\makebox(0,0)[r]{$0.8$}}
\put(1419.0,704.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(110.0,859.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(90,859){\makebox(0,0)[r]{$1$}}
\put(1419.0,859.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
\put(110.0,82.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(110,41){\makebox(0,0){$0$}}
\put(110.0,839.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(322.0,82.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(322,41){\makebox(0,0){$1$}}
\put(322.0,839.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(533.0,82.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(533,41){\makebox(0,0){$2$}}
\put(533.0,839.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(745.0,82.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(745,41){\makebox(0,0){$3$}}
\put(745.0,839.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(956.0,82.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(956,41){\makebox(0,0){$4$}}
\put(956.0,839.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(1168.0,82.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(1168,41){\makebox(0,0){$5$}}
\put(1168.0,839.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(1380.0,82.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(1380,41){\makebox(0,0){$6$}}
\put(1380.0,839.0){\rule[-0.200pt]{0.400pt}{4.818pt}}
\put(110.0,82.0){\rule[-0.200pt]{0.400pt}{187.179pt}}
\put(110.0,82.0){\rule[-0.200pt]{320.156pt}{0.400pt}}
\put(1439.0,82.0){\rule[-0.200pt]{0.400pt}{187.179pt}}
\put(110.0,859.0){\rule[-0.200pt]{320.156pt}{0.400pt}}
\put(110,82){\usebox{\plotpoint}}
\multiput(110.58,82.00)(0.493,1.924){23}{\rule{0.119pt}{1.608pt}}
\multiput(109.17,82.00)(13.000,45.663){2}{\rule{0.400pt}{0.804pt}}
\multiput(123.58,131.00)(0.494,1.782){25}{\rule{0.119pt}{1.500pt}}
\multiput(122.17,131.00)(14.000,45.887){2}{\rule{0.400pt}{0.750pt}}
\multiput(137.58,180.00)(0.493,1.924){23}{\rule{0.119pt}{1.608pt}}
\multiput(136.17,180.00)(13.000,45.663){2}{\rule{0.400pt}{0.804pt}}
\multiput(150.58,229.00)(0.494,1.745){25}{\rule{0.119pt}{1.471pt}}
\multiput(149.17,229.00)(14.000,44.946){2}{\rule{0.400pt}{0.736pt}}
\multiput(164.58,277.00)(0.493,1.845){23}{\rule{0.119pt}{1.546pt}}
\multiput(163.17,277.00)(13.000,43.791){2}{\rule{0.400pt}{0.773pt}}
\multiput(177.58,324.00)(0.494,1.709){25}{\rule{0.119pt}{1.443pt}}
\multiput(176.17,324.00)(14.000,44.005){2}{\rule{0.400pt}{0.721pt}}
\multiput(191.58,371.00)(0.493,1.765){23}{\rule{0.119pt}{1.485pt}}
\multiput(190.17,371.00)(13.000,41.919){2}{\rule{0.400pt}{0.742pt}}
\multiput(204.58,416.00)(0.493,1.726){23}{\rule{0.119pt}{1.454pt}}
\multiput(203.17,416.00)(13.000,40.982){2}{\rule{0.400pt}{0.727pt}}
\multiput(217.58,460.00)(0.494,1.525){25}{\rule{0.119pt}{1.300pt}}
\multiput(216.17,460.00)(14.000,39.302){2}{\rule{0.400pt}{0.650pt}}
\multiput(231.58,502.00)(0.493,1.567){23}{\rule{0.119pt}{1.331pt}}
\multiput(230.17,502.00)(13.000,37.238){2}{\rule{0.400pt}{0.665pt}}
\multiput(244.58,542.00)(0.494,1.415){25}{\rule{0.119pt}{1.214pt}}
\multiput(243.17,542.00)(14.000,36.480){2}{\rule{0.400pt}{0.607pt}}
\multiput(258.58,581.00)(0.493,1.448){23}{\rule{0.119pt}{1.238pt}}
\multiput(257.17,581.00)(13.000,34.430){2}{\rule{0.400pt}{0.619pt}}
\multiput(271.58,618.00)(0.494,1.268){25}{\rule{0.119pt}{1.100pt}}
\multiput(270.17,618.00)(14.000,32.717){2}{\rule{0.400pt}{0.550pt}}
\multiput(285.58,653.00)(0.493,1.250){23}{\rule{0.119pt}{1.085pt}}
\multiput(284.17,653.00)(13.000,29.749){2}{\rule{0.400pt}{0.542pt}}
\multiput(298.58,685.00)(0.493,1.171){23}{\rule{0.119pt}{1.023pt}}
\multiput(297.17,685.00)(13.000,27.877){2}{\rule{0.400pt}{0.512pt}}
\multiput(311.58,715.00)(0.494,0.974){25}{\rule{0.119pt}{0.871pt}}
\multiput(310.17,715.00)(14.000,25.191){2}{\rule{0.400pt}{0.436pt}}
\multiput(325.58,742.00)(0.493,0.972){23}{\rule{0.119pt}{0.869pt}}
\multiput(324.17,742.00)(13.000,23.196){2}{\rule{0.400pt}{0.435pt}}
\multiput(338.58,767.00)(0.494,0.791){25}{\rule{0.119pt}{0.729pt}}
\multiput(337.17,767.00)(14.000,20.488){2}{\rule{0.400pt}{0.364pt}}
\multiput(352.58,789.00)(0.493,0.734){23}{\rule{0.119pt}{0.685pt}}
\multiput(351.17,789.00)(13.000,17.579){2}{\rule{0.400pt}{0.342pt}}
\multiput(365.58,808.00)(0.493,0.616){23}{\rule{0.119pt}{0.592pt}}
\multiput(364.17,808.00)(13.000,14.771){2}{\rule{0.400pt}{0.296pt}}
\multiput(378.00,824.58)(0.536,0.493){23}{\rule{0.531pt}{0.119pt}}
\multiput(378.00,823.17)(12.898,13.000){2}{\rule{0.265pt}{0.400pt}}
\multiput(392.00,837.58)(0.652,0.491){17}{\rule{0.620pt}{0.118pt}}
\multiput(392.00,836.17)(11.713,10.000){2}{\rule{0.310pt}{0.400pt}}
\multiput(405.00,847.59)(1.026,0.485){11}{\rule{0.900pt}{0.117pt}}
\multiput(405.00,846.17)(12.132,7.000){2}{\rule{0.450pt}{0.400pt}}
\multiput(419.00,854.60)(1.797,0.468){5}{\rule{1.400pt}{0.113pt}}
\multiput(419.00,853.17)(10.094,4.000){2}{\rule{0.700pt}{0.400pt}}
\put(432,857.67){\rule{3.373pt}{0.400pt}}
\multiput(432.00,857.17)(7.000,1.000){2}{\rule{1.686pt}{0.400pt}}
\put(446,857.17){\rule{2.700pt}{0.400pt}}
\multiput(446.00,858.17)(7.396,-2.000){2}{\rule{1.350pt}{0.400pt}}
\multiput(459.00,855.93)(1.123,-0.482){9}{\rule{0.967pt}{0.116pt}}
\multiput(459.00,856.17)(10.994,-6.000){2}{\rule{0.483pt}{0.400pt}}
\multiput(472.00,849.93)(0.890,-0.488){13}{\rule{0.800pt}{0.117pt}}
\multiput(472.00,850.17)(12.340,-8.000){2}{\rule{0.400pt}{0.400pt}}
\multiput(486.00,841.92)(0.539,-0.492){21}{\rule{0.533pt}{0.119pt}}
\multiput(486.00,842.17)(11.893,-12.000){2}{\rule{0.267pt}{0.400pt}}
\multiput(499.00,829.92)(0.497,-0.494){25}{\rule{0.500pt}{0.119pt}}
\multiput(499.00,830.17)(12.962,-14.000){2}{\rule{0.250pt}{0.400pt}}
\multiput(513.58,814.29)(0.493,-0.695){23}{\rule{0.119pt}{0.654pt}}
\multiput(512.17,815.64)(13.000,-16.643){2}{\rule{0.400pt}{0.327pt}}
\multiput(526.58,796.21)(0.494,-0.717){25}{\rule{0.119pt}{0.671pt}}
\multiput(525.17,797.61)(14.000,-18.606){2}{\rule{0.400pt}{0.336pt}}
\multiput(540.58,775.52)(0.493,-0.933){23}{\rule{0.119pt}{0.838pt}}
\multiput(539.17,777.26)(13.000,-22.260){2}{\rule{0.400pt}{0.419pt}}
\multiput(553.58,751.26)(0.493,-1.012){23}{\rule{0.119pt}{0.900pt}}
\multiput(552.17,753.13)(13.000,-24.132){2}{\rule{0.400pt}{0.450pt}}
\multiput(566.58,725.26)(0.494,-1.011){25}{\rule{0.119pt}{0.900pt}}
\multiput(565.17,727.13)(14.000,-26.132){2}{\rule{0.400pt}{0.450pt}}
\multiput(580.58,696.63)(0.493,-1.210){23}{\rule{0.119pt}{1.054pt}}
\multiput(579.17,698.81)(13.000,-28.813){2}{\rule{0.400pt}{0.527pt}}
\multiput(593.58,665.55)(0.494,-1.231){25}{\rule{0.119pt}{1.071pt}}
\multiput(592.17,667.78)(14.000,-31.776){2}{\rule{0.400pt}{0.536pt}}
\multiput(607.58,631.11)(0.493,-1.369){23}{\rule{0.119pt}{1.177pt}}
\multiput(606.17,633.56)(13.000,-32.557){2}{\rule{0.400pt}{0.588pt}}
\multiput(620.58,596.08)(0.494,-1.378){25}{\rule{0.119pt}{1.186pt}}
\multiput(619.17,598.54)(14.000,-35.539){2}{\rule{0.400pt}{0.593pt}}
\multiput(634.58,557.48)(0.493,-1.567){23}{\rule{0.119pt}{1.331pt}}
\multiput(633.17,560.24)(13.000,-37.238){2}{\rule{0.400pt}{0.665pt}}
\multiput(647.58,517.35)(0.493,-1.607){23}{\rule{0.119pt}{1.362pt}}
\multiput(646.17,520.17)(13.000,-38.174){2}{\rule{0.400pt}{0.681pt}}
\multiput(660.58,476.48)(0.494,-1.562){25}{\rule{0.119pt}{1.329pt}}
\multiput(659.17,479.24)(14.000,-40.242){2}{\rule{0.400pt}{0.664pt}}
\multiput(674.58,432.96)(0.493,-1.726){23}{\rule{0.119pt}{1.454pt}}
\multiput(673.17,435.98)(13.000,-40.982){2}{\rule{0.400pt}{0.727pt}}
\multiput(687.58,389.13)(0.494,-1.672){25}{\rule{0.119pt}{1.414pt}}
\multiput(686.17,392.06)(14.000,-43.065){2}{\rule{0.400pt}{0.707pt}}
\multiput(701.58,342.58)(0.493,-1.845){23}{\rule{0.119pt}{1.546pt}}
\multiput(700.17,345.79)(13.000,-43.791){2}{\rule{0.400pt}{0.773pt}}
\multiput(714.58,295.89)(0.494,-1.745){25}{\rule{0.119pt}{1.471pt}}
\multiput(713.17,298.95)(14.000,-44.946){2}{\rule{0.400pt}{0.736pt}}
\multiput(728.58,247.45)(0.493,-1.884){23}{\rule{0.119pt}{1.577pt}}
\multiput(727.17,250.73)(13.000,-44.727){2}{\rule{0.400pt}{0.788pt}}
\multiput(741.58,199.33)(0.493,-1.924){23}{\rule{0.119pt}{1.608pt}}
\multiput(740.17,202.66)(13.000,-45.663){2}{\rule{0.400pt}{0.804pt}}
\multiput(754.58,150.77)(0.494,-1.782){25}{\rule{0.119pt}{1.500pt}}
\multiput(753.17,153.89)(14.000,-45.887){2}{\rule{0.400pt}{0.750pt}}
\multiput(768.59,101.42)(0.485,-1.942){11}{\rule{0.117pt}{1.586pt}}
\multiput(767.17,104.71)(7.000,-22.709){2}{\rule{0.400pt}{0.793pt}}
\put(110.0,82.0){\rule[-0.200pt]{0.400pt}{187.179pt}}
\put(110.0,82.0){\rule[-0.200pt]{320.156pt}{0.400pt}}
\put(1439.0,82.0){\rule[-0.200pt]{0.400pt}{187.179pt}}
\put(110.0,859.0){\rule[-0.200pt]{320.156pt}{0.400pt}}
\end{picture}
现在您保存了上面的tex文件,并且您将在tex文档中包含 tex 文件作为图形,但它绝不会是我认为的PDF文件。
答案 0 :(得分:1)
如果由于某种原因你不想使用tikz和优秀的tikzDevice package,你可以试试?pictex
,但its help page表明它并不完全操作。
pictex()
plot(1,1)
dev.off()
\hbox{\beginpicture
\setcoordinatesystem units <1pt,1pt>
\setplotarea x from 0 to 361.35, y from 0 to 289.08
\setlinear
\font\picfont cmss10\picfont
\font\picfont cmss10 at 10pt\picfont
\font\picfont cmss10 at 10pt\picfont
\circulararc 360 degrees from 180.68 164.79 center at 180.68 162.54
\setsolid
\plot 58.94 61.20 302.41 61.20 /
\setsolid
\plot 58.94 61.20 58.94 55.20 /
\setsolid
\plot 119.81 61.20 119.81 55.20 /
\setsolid
\plot 180.68 61.20 180.68 55.20 /
\setsolid
\plot 241.54 61.20 241.54 55.20 /
\setsolid
\plot 302.41 61.20 302.41 55.20 /
\put {0.6} [lB] <0.00pt,0.00pt> at 52.55 37.20
\put {0.8} [lB] <0.00pt,0.00pt> at 113.42 37.20
\put {1.0} [lB] <0.00pt,0.00pt> at 174.29 37.20
\put {1.2} [lB] <0.00pt,0.00pt> at 235.15 37.20
\put {1.4} [lB] <0.00pt,0.00pt> at 296.02 37.20
\setsolid
\plot 49.20 68.71 49.20 256.37 /
\setsolid
\plot 49.20 68.71 43.20 68.71 /
\setsolid
\plot 49.20 115.62 43.20 115.62 /
\setsolid
\plot 49.20 162.54 43.20 162.54 /
\setsolid
\plot 49.20 209.46 43.20 209.46 /
\setsolid
\plot 49.20 256.37 43.20 256.37 /
\put {\rotatebox{90}{0.6} } [rB] <0.00pt,0.00pt> at 37.20 62.32
\put {\rotatebox{90}{0.8} } [rB] <0.00pt,0.00pt> at 37.20 109.23
\put {\rotatebox{90}{1.0} } [rB] <0.00pt,0.00pt> at 37.20 156.15
\put {\rotatebox{90}{1.2} } [rB] <0.00pt,0.00pt> at 37.20 203.07
\put {\rotatebox{90}{1.4} } [rB] <0.00pt,0.00pt> at 37.20 249.98
\setsolid
\plot 49.20 61.20 312.15 61.20 /
\plot 312.15 61.20 312.15 263.88 /
\plot 312.15 263.88 49.20 263.88 /
\plot 49.20 263.88 49.20 61.20 /
\put {1} [lB] <0.00pt,0.00pt> at 178.17 13.20
\put {\rotatebox{90}{1} } [rB] <0.00pt,0.00pt> at 13.20 160.04
\endpicture
}
最后一种方法,编写自己的设备,或使用R-gnuplot界面(TeachingDemos有一个,apparently),但我非常怀疑它是否值得。