注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

随机过程

http://superware.blog.163.com

 
 
 

日志

 
 

Epslatex in gnuplot (I)  

2015-01-23 16:40:34|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

1. Preparing  gnuplot file included.gnuplot

set terminal epslatex standalone color

set output 'included.tex'

set multiplot
set samples 5000
set grid
set xtics ('$0.0$' 0.0, '$\frac{1}{2}\pi$' pi/2, '$\pi$' pi, '$\frac{3}{2}\pi$' 3*pi/2, '$2\pi$' 2*pi)
set ytics 10.0
set key top right
plot [0:2*pi] exp(x)*sin(1/x) title '$e^x\sin\left(\frac{1}{x}\right)$'
unset multiplot


2. Writing bash script gnuepsplot.sh

#!/bin/bash

if [ $# != 1 ]; then
echo Usage: $0 filename.
else
full_name=$1
file=$(basename "$full_name")
prefix="${file%.*}"
suffix="${file##*.}"

echo
echo "============= Parameters ================="
echo "File name : ${prefix}"
echo "Extension : ${suffix}"

str=`awk '/output/ {print $3}' ${file}`

echo "Tex file name : ${str:1:(${#str}-2)}"
echo "============= Parameters ================="
echo

substr=${str:1:(${#str}-2)}

sed '/output/ d' ${file} > output
sed "1 a \set output \'${substr}\'" output > output.gnuplot

gnuplot output.gnuplot
pdflatex ${substr}

rmstr="${file%.*}"

rm output ${rmstr}.aux ${rmstr}-inc.eps ${rmstr}-inc-eps-converted-to.pdf ${rmstr}.log
fi


3. Running

$ ./gnuepsplot.sh included.gnuplot

...


$ ls

included.gnuplot included.gnuplot included.tex output.gnuplot


Epslatex in gnuplot - superware - 随机过程
 

4. Listing the contex of include.tex file

% GNUPLOT: LaTeX picture with Postscript
\documentclass{minimal}
% Set font size
\makeatletter
\def\@ptsize{1}
\InputIfFileExists{size11.clo}{}{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Gnuplot Error: File `size11.clo' not found! Could not set font size%
}{See the gnuplot documentation for explanation.%
}{For using a font size a file `size<fontsize>.clo' has to exist.
Falling back ^^Jto default fontsize 10pt.}%
\def\@ptsize{0}
\input{size10.clo}%
}%
\makeatother
% Load packages
\usepackage{graphicx}
\usepackage{color}
\makeatletter
% Select an appropriate default driver (from TeXLive graphics.cfg)
\begingroup
\chardef\x=0 %
% check pdfTeX
\@ifundefined{pdfoutput}{}{%
\ifcase\pdfoutput
\else
\chardef\x=1 %
\fi
}%
% check VTeX
\@ifundefined{OpMode}{}{%
\chardef\x=2 %
}%
\expandafter\endgroup
\ifcase\x
% default case
\PassOptionsToPackage{dvips}{geometry}
\or
% pdfTeX is running in pdf mode
\PassOptionsToPackage{pdftex}{geometry}
\else
% VTeX is running
\PassOptionsToPackage{vtex}{geometry}
\fi
\makeatother
% Set papersize
\usepackage[papersize={360.00bp,252.00bp},text={360.00bp,252.00bp}]{geometry}
% No page numbers and no paragraph indentation
\pagestyle{empty}
\setlength{\parindent}{0bp}%
% Load configuration file
\InputIfFileExists{gnuplot.cfg}{%
\typeout{Using configuration file gnuplot.cfg}%
}{%
\typeout{No configuration file gnuplot.cfg found.}%
}%
%
\begin{document}
\begingroup
\makeatletter
\providecommand\color[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Package color not loaded in conjunction with
terminal option `colourtext'%
}{See the gnuplot documentation for explanation.%
}{Either use 'blacktext' in gnuplot or load the package
color.sty in LaTeX.}%
\renewcommand\color[2][]{}%
}%
\providecommand\includegraphics[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Package graphicx or graphics not loaded%
}{See the gnuplot documentation for explanation.%
}{The gnuplot epslatex terminal needs graphicx.sty or graphics.sty.}%
\renewcommand\includegraphics[2][]{}%
}%
\providecommand\rotatebox[2]{#2}%
\@ifundefined{ifGPcolor}{%
\newif\ifGPcolor
\GPcolortrue
}{}%
\@ifundefined{ifGPblacktext}{%
\newif\ifGPblacktext
\GPblacktexttrue
}{}%
% define a \g@addto@macro without @ in the name:
\let\gplgaddtomacro\g@addto@macro
% define empty templates for all commands taking text:
\gdef\gplbacktext{}%
\gdef\gplfronttext{}%
\makeatother
\ifGPblacktext
% no textcolor at all
\def\colorrgb#1{}%
\def\colorgray#1{}%
\else
% gray or color?
\ifGPcolor
\def\colorrgb#1{\color[rgb]{#1}}%
\def\colorgray#1{\color[gray]{#1}}%
\expandafter\def\csname LTw\endcsname{\color{white}}%
\expandafter\def\csname LTb\endcsname{\color{black}}%
\expandafter\def\csname LTa\endcsname{\color{black}}%
\expandafter\def\csname LT0\endcsname{\color[rgb]{1,0,0}}%
\expandafter\def\csname LT1\endcsname{\color[rgb]{0,1,0}}%
\expandafter\def\csname LT2\endcsname{\color[rgb]{0,0,1}}%
\expandafter\def\csname LT3\endcsname{\color[rgb]{1,0,1}}%
\expandafter\def\csname LT4\endcsname{\color[rgb]{0,1,1}}%
\expandafter\def\csname LT5\endcsname{\color[rgb]{1,1,0}}%
\expandafter\def\csname LT6\endcsname{\color[rgb]{0,0,0}}%
\expandafter\def\csname LT7\endcsname{\color[rgb]{1,0.3,0}}%
\expandafter\def\csname LT8\endcsname{\color[rgb]{0.5,0.5,0.5}}%
\else
% gray
\def\colorrgb#1{\color{black}}%
\def\colorgray#1{\color[gray]{#1}}%
\expandafter\def\csname LTw\endcsname{\color{white}}%
\expandafter\def\csname LTb\endcsname{\color{black}}%
\expandafter\def\csname LTa\endcsname{\color{black}}%
\expandafter\def\csname LT0\endcsname{\color{black}}%
\expandafter\def\csname LT1\endcsname{\color{black}}%
\expandafter\def\csname LT2\endcsname{\color{black}}%
\expandafter\def\csname LT3\endcsname{\color{black}}%
\expandafter\def\csname LT4\endcsname{\color{black}}%
\expandafter\def\csname LT5\endcsname{\color{black}}%
\expandafter\def\csname LT6\endcsname{\color{black}}%
\expandafter\def\csname LT7\endcsname{\color{black}}%
\expandafter\def\csname LT8\endcsname{\color{black}}%
\fi
\fi
\setlength{\unitlength}{0.0500bp}%
\begin{picture}(7200.00,5040.00)%
\gplgaddtomacro\gplbacktext{%
\csname LTb\endcsname%
\put(594,440){\makebox(0,0)[r]{\strut{}-10}}%
\csname LTb\endcsname%
\put(594,874){\makebox(0,0)[r]{\strut{} 0}}%
\csname LTb\endcsname%
\put(594,1307){\makebox(0,0)[r]{\strut{} 10}}%
\csname LTb\endcsname%
\put(594,1741){\makebox(0,0)[r]{\strut{} 20}}%
\csname LTb\endcsname%
\put(594,2174){\makebox(0,0)[r]{\strut{} 30}}%
\csname LTb\endcsname%
\put(594,2608){\makebox(0,0)[r]{\strut{} 40}}%
\csname LTb\endcsname%
\put(594,3041){\makebox(0,0)[r]{\strut{} 50}}%
\csname LTb\endcsname%
\put(594,3475){\makebox(0,0)[r]{\strut{} 60}}%
\csname LTb\endcsname%
\put(594,3908){\makebox(0,0)[r]{\strut{} 70}}%
\csname LTb\endcsname%
\put(594,4342){\makebox(0,0)[r]{\strut{} 80}}%
\csname LTb\endcsname%
\put(594,4775){\makebox(0,0)[r]{\strut{} 90}}%
\csname LTb\endcsname%
\put(726,220){\makebox(0,0){\strut{}$0.0$}}%
\csname LTb\endcsname%
\put(2245,220){\makebox(0,0){\strut{}$\frac{1}{2}\pi$}}%
\csname LTb\endcsname%
\put(3765,220){\makebox(0,0){\strut{}$\pi$}}%
\csname LTb\endcsname%
\put(5284,220){\makebox(0,0){\strut{}$\frac{3}{2}\pi$}}%
\csname LTb\endcsname%
\put(6803,220){\makebox(0,0){\strut{}$2\pi$}}%
}%
\gplgaddtomacro\gplfronttext{%
\csname LTb\endcsname%
\put(5816,4602){\makebox(0,0)[r]{\strut{}$e^x\sin\left(\frac{1}{x}\right)$}}%
}%
\gplbacktext
\put(0,0){\includegraphics{included-inc}}%
\gplfronttext
\end{picture}%
\endgroup
\end{document}

  评论这张
 
阅读(94)| 评论(0)
推荐

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017