当前位置:   article > 正文

tikz绘图学习(长期更新)

tikz绘图

tikz基于latex

tikz生成的图片只能是嵌入在pdf中的,要想转换成其他格式还需要额外的处理,例如使用imagegick.

tikz right of的用法

在这里插入图片描述
见上图,使用right of可以精确的控制legend的位置。上图就是精确的将legend控制在了点(-1, 2)右侧.

inkscape应该无法直接导出tikz code

只能通过第三方开源的插件或软件svg2tikz实现导出tikz code
在这里插入图片描述冒号代表极坐标,上面的意思是坐标(1,140度)处

node在tikz中是一个很重要的思想,公切线和圆的图片、流程图都可以用node实现

\foreach

\foreach \x/\y in {0/0,0/1}这样可以实现多个参数的传递

我想实现的:
1.节点距离自由控制;
2.字体自由控制
\itshape的意思就是意大利斜体。

坐标重置

我观看的教学视频
问题:画折线找坐标时可以坐标重置,那么画流程图可不可以呢?

记得导入该导入的

\documentclass[a4paper,10pt]{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{positioning}

\tikzstyle{input} = [rectangle,minimum width=2.75cm,minimum height=1cm,text centered,text width =3cm,draw=black,ultra thick]
\tikzstyle{encoder_convolution_block} = [rectangle,minimum width=3cm,minimum height=0.78cm,text centered,text width =3cm,draw=black,fill=green!32]
\tikzstyle{encoder_fc_block} = [rectangle,minimum width=3cm,minimum height=0.78cm,text centered,text width =3cm,draw=black,fill=green!64!yellow]
\tikzstyle{decoder_convolution_block} = [rectangle,minimum width=3cm,minimum height=1cm,text centered,text width =3cm,draw=black,fill=blue!35]
\tikzstyle{discriminator_convolution_block} = [rectangle,minimum width=3cm,minimum height=1cm,text centered,text width =3cm,draw=black,fill=red!35]


\begin{document}

\begin{tikzpicture}[node distance=2cm]

    \node[input]  (input) {Input};
    \node[encoder_convolution_block, below=of input]  (ec1) {3×3,conv,32,/2};
    \node[encoder_convolution_block,below=of ec1] (ec2) {3×3,conv,64,/2};
    \node[encoder_convolution_block,below=of ec2] (ec3) {3×3,conv,128,/2};
    \node[encoder_convolution_block,below=of ec3]  (eflat) {Flatten};
    \node[encoder_fc_block,below=of eflat] (efc) {fc,16};
    \node[encoder_fc_block, left=100pt of efc] (mean) {$\mu_{z}$,16};
    \node[encoder_fc_block,below right= of efc] (std) {$\sigma_{z}$,16};

% \node (process1) [process,below of=input1] {Process 1};
% \node (decision1) [decision,below of=process1,yshift=-0.5cm] {Decession 1};
% \node (process2a) [process,below of=decision1,yshift=-0.5cm] {Process 2aaaaaa aaaaaaa aaaa};
% \node (process2b) [process,right of =decision1,xshift=2cm] {Process 2b};
% \node (out1) [io,below of=process2a] {Output};
% \node (stop) [startstop,below of=out1] {Stop};

% \draw [arrow] (start) -- (input1);
% \draw [arrow] (input1) -- (process1);
% \draw [arrow] (process1) -- (decision1);
% \draw [arrow] (decision1) -- node[anchor=east] {yes} (process2a);
% \draw [arrow] (decision1) -- node[anchor=south] {no} (process2b);
% \draw [arrow] (process2b) |- (process1);
% \draw [arrow] (process2a) -- (out1);
% \draw [arrow] (out1) -- (stop);

\end{tikzpicture}


\end{document}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47

上面代码第六行,如果把这一行删掉,即不导入positioning包,那么会报8个错:Package PGF Math Error: Unknown function `of’ (in ‘of input’).
在不导入positioning包的情况下,数值设置below=10pt功能也不能使用。

在这里插入图片描述
见上图,当below right=0cm时,efc的右下角和std的左上角重合。我猜这个0cm的位置参数就是指这两个点的相对距离了。方向应该是正负45度线。

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
  

闽ICP备14008679号