论文写作+gnuplot制图

一:论文写作

论文写作推荐使用LATEX+TEXStudio+TEXLive

1.CTeX官方网站:http://www.ctex.org/HomePage ,他类似于python环境

2.TeXstudio下载地址:http://texstudio.sourceforge.net/ ,他类似于PyCharm,用它编写代码更方便,比CTEX自带的WinEdt编辑更好用,类似于记事本和IDE的关系

3.TEXLive下载地址:https://www.tug.org/texlive/  ,知道安装网址:https://www.jianshu.com/p/25896cc05cb4 ,他类似于Anacoda,下载他以后,相关的package都可以自动导入,免去自己一个个在网上找包的痛苦,比如写算法时Algorithm包或Algorithm2e包,都可以自动导入,又或者在网上下载的LATEX模板,缺少很多包,也可以直接通过TEXLive导入

算法模板:

\documentclass[10.5pt]{article}

\usepackage{algorithm}  
\usepackage[noend]{algorithmic}
\usepackage{amsmath}  
\usepackage{bm}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}  % Use Input in the format of Algorithm  
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm

\begin{document}
    {\small
        \begin{algorithm}
            \caption{Algorithm for joint deployment and routing}\label{alg:pce}
            \begin{algorithmic}[1]
                \REQUIRE network topology G(V$\cup$ L,E),$\gamma _i=<s_i,t_i,b_i,SC_i> \in \Gamma$
                \ENSURE $x_{i,l},y_{o,l}$ and the selected path of each $\gamma_i$ \\
                $\bm{Step 1:Calculating \ feasible \ paths \ and \ link \  bandwidth}$
                \FOR{all $\gamma \in \Gamma$}
                \FOR{all l $\in$ L}
                \STATE $cost_{\gamma ,l} \Leftarrow $the cost of request $\gamma$ traverse PM l
                \ENDFOR
                \STATE Select three PMs with low cost as the feasible path PMs
                \STATE $P_\gamma \Leftarrow$ the set of feasible paths
                \FOR{all path in $P_\gamma$}
                \FOR{all e $\in$ E}
                \IF{$\gamma$ traverse e}
                \STATE $B_e \Leftarrow B_e +d_\gamma$
                \ENDIF
                \ENDFOR
                \IF{$\left \{B_e \right \} > b_e$}
                \STATE remove path from $P_\gamma$
                \ENDIF
                \STATE $B_{path} \Leftarrow B_{path} \cup \left \{B_e \right \}$
                \ENDFOR
                \STATE P = P $\cup P_\gamma,$B = B$\cup \left \{ B_{path} \right \}$
                \ENDFOR
                $\bm{Step 2:Sorting \ the \ link \ bandwidth}$
                \FOR{$SC_i \in SCs$}
                \STATE $X_i = \left \{ \right \}$ //the set of $x_{i,l}$
                \STATE $\Gamma_i \Leftarrow$ the flow set of traverse $SC_i$
                \FOR{all $\gamma \in \Gamma_i$}
                \FOR{all path $\in$ $P_\gamma$}
                \STATE $B_i = B_i \cup B_{path}$
                \ENDFOR
                \ENDFOR
                \STATE Order $\lambda_i$ in non-decreasing degree order and set $X_i \leftarrow x_{i,l}$,$P_i \leftarrow y_{\gamma ,p}$
                \STATE $\lambda = \lambda \cup \lambda_i$
                \ENDFOR
                $\bm{Step 3:Updating \ the \ forwarding \ table \ capacity}$
                \FOR{all v $\in$ V}
                \STATE $y_{o,l}=0$
                \IF{the forwarding table capacity of switch v does not satify Eq.(3)}
                \STATE remove $x_{i,l}$ from $X_i$ and $y_{\gamma ,p}$ from $P_i$
                \ELSIF{$y_{o,l} == 0$ is not satified Eq.(4)}
                \STATE $y_{o,l}=1$
                \ENDIF
                \STATE $Y = y \cup y_{o,l}$
                \ENDFOR
                $\bm{Step 4:Calculating \ the \ number \ of \ cores \ using \ CPU \ per \  PM}$
                \FOR{all l $\in$ L}
                \FOR{$SC_i \in SCs$}
                \IF{the number of CPU cores of PM l is satisfied Eq.(1)}
                \STATE $R_l \Leftarrow R_l - (x_{i,l} \times y_{i,l}+y_{o,l} \times y(o,l))$
                \ELSE
                \STATE remove $y_{o,l},x_{i,l}$ and $P_i$
                \ENDIF
                \ENDFOR
                \ENDFOR    
            \end{algorithmic}
    \end{algorithm}}
\end{document}

效果如下:

 

 二:论文eps图

论文中eps图我首先使用gnuplot这个轻量级作图软件制成pdf图,然后通过TEXLive中自带软件把xxx.pdf  -》 xxx.ps -> xxx.eps

1.gunplot制图

gunplot下载地址: http://www.gnuplot.info/ 

绘图时把数据写成.xxx,dat格式,如下

#LINK N proposed ALG-1 ALG-2
A 6 1.35146 1.35146 2.61590
B 12 2.63290 2.63290 4.95446
C 18 4.19496 4.19496 6.79023
D 24 5.51183 5.51183 8.20803
E 30 8.59923 8.59923 12.91023
F 36 8.59923 8.59923 14.67736
G 42 9.90530 9.90530 16.56306
H 48 11.57430 11.57430 20.36260
I 54 12.88210 12.88210 22.89410
J 60 14.72120 14.72120 25.10080


在编写制图代码:

png格式的图:

set terminal png font "Microsoft YaHei, 9"
set output '04biggestLinkLoad.png'

set key left reverse Left spacing 1.2

set xlabel "No. of Requests(x 10^3)"
set ylabel "Max. Link Load(Gpbs)"

file = "04biggestLinkLoad.dat"

set pointsize 2
plot file u 2:3 with linespoint pointtype 4 linewidth 2 dashtype 5 t "proposed",\
     file u 2:4 with linespoint pointtype 6 linewidth 2 t "ALG-1",\
     file u 2:5 with linespoint pointtype 8 linewidth 2 t "ALG-2"

效果:

pdf格式的图:

set terminal png font "Microsoft YaHei, 9"
set output '04biggestLinkLoad.png'

set key left reverse Left spacing 1.2

set xlabel "No. of Requests(x 10^3)"
set ylabel "Max. Link Load(Gpbs)"

file = "04biggestLinkLoad.dat"

set pointsize 2
plot file u 2:3 with linespoint pointtype 4 linewidth 2 dashtype 5 t "proposed",\
     file u 2:4 with linespoint pointtype 6 linewidth 2 t "ALG-1",\
     file u 2:5 with linespoint pointtype 8 linewidth 2 t "ALG-2"

效果:

 

 2.将xxx.pdf文件转换成xxx.eps文件

 在xxx\xxx\texlive\2019\bin\win32下有两个exe文件,其中pdfops是用于将xxx.pdf文件转为xxx.ps文件,ps2eps可用于xxx.ps文件转化为xxx.eps文件,具体步骤如下:

2.1找到windos的cmd,进入xxx\xxx\texlive\2019\bin\win32目录

cd D:
cd xxx\texlive\2019\bin\win32

2.2 运行命令 pdftops xxx.pdf   (生成ps文件)

2.3 运行命令 ps2eps xxx.ps    (生成eps文件)

 备:visio生成的pdf图有边框,去除的办法

1. 在visio中,选  设计----大小----适应绘图;此时可发现图片虽被自适应,但虚线到外边框还有白色空白,下面去空白;


2. 点 文件---选项-----自定义功能(在弹出对话框的左侧)-----勾上开发工具(在右侧)----保存


3. 在visio的上面工具一栏会发现多了开发工具(developer),点 开发工具------显示shapeSheet-----页-----在打开的选项卡中找到“print properties”,

将“PageLeftMargin”、“PageRightMargin”、“PageTopMargin”和“PageBottomMargin”均修改为0(上方有类似于excel的编辑的小窗口,下边右上方有关闭按钮),关闭表格。

 

4. 再将步骤1操作一次,自适应绘图,发现已去除空白;


5. 另存为pdf 注意:保存时先选pdf格式,然后点 “选项(option)”-----在弹出的对话框中将“辅助功能文档结构标记”前的勾去掉-----点击“确定”,保存就好了;


6. 用acrobat 将保存的pdf打开,另存为eps格式;


7. 再次编译latex查看结果,发现生成的图片分辨率高,且已经没有了外边框。。。


8. 结束。

posted @ 2020-02-09 18:26  冲向云霄1998  阅读(516)  评论(0编辑  收藏  举报