唱唱反调

  • 灵与肉
  • 声与形
  • Freeland
  • FLAG
  1. 首页
  2. Freeland
  3. 正文

如何插入矢量图

2022年 6月 8日   鹌鹑

Tikzjax引擎

在页首添加如下JavaScript:

<link rel=stylesheet type=text/css href=http://tikzjax.com/v1/fonts.css>
<script src=http://tikzjax.com/v1/tikzjax.js></script>

TikZJax会将指令转化为SVG矢量图并显示在页面上(加载时间与网络有关)。比如我们要画一个半径为1的圆,我们输入如下代码:

<script type=text/tikz>
  \begin{tikzpicture}
    \draw (0,0) circle (1in);
  \end{tikzpicture}
</script>

我们会得到下图

对于一般的曲线我们选取多个节点,通过控制磨光画出:

<script type=text/tikz>
\begin{tikzpicture}
\draw[style=help lines,step=1cm] (-3,-3) grid (3,3);
\draw[thick]  plot [smooth,tension=0.8] 
coordinates {(-3,0.8) (-1.5,3.2) (1.8,2.8) (3.1,0.8)
(2.5,-2.2)  (0.2,-1.5) (-3,-3.5) (-3,0.8)};

\node at (1.6,1.6){I Love U$x+y+\Omega+\Sigma$};
\end{tikzpicture}
</script>

这里\draw[style=help lines, step=1cm] (-3,3) grid (3,3)画出了辅助方格图,在指定坐标可用\node at添加文字或tex((tikz中无法输出$\Omega$,而$\Gamma$会被输出为$\Theta$,可能是bug.))。得到的图形如下

下面为通过plot正弦函数绘制的三维图像:

<script type=text/tikz>
\begin{tikzpicture}[x={(1cm,0.5cm)},z={(0cm,0.5cm)},y={(1cm,-0.2cm)}]
\draw[->,thick,black!70] (0,6.5,0) -- (6.2,6.5,0) node[right] {Frequency};
\draw[->,thick,black!70] (0,0,0) -- (0,6.5,0) node[below right] {Time}; 
\draw[->,thick] (0,0,0) -- (0,0,2) node[above] {Magnitude}; 

\foreach \n in {0.5,1.5,...,5.5}{
\draw [cyan!50, domain=0:2*pi,samples=200,smooth] 
 plot (\n,\x, {sin(4*\n*\x r)/\n });
\draw[blue, ultra thick] (\n,6.5,0) -- (\n,6.5,1/\n);
}

\draw [red, thick, domain=0:2*pi,samples=200,smooth] 
plot (0,\x, {sin(4*0.5*\x r)/0.5 + sin(4*1.5*\x r)/1.5 + sin(4*2.5*\x r)/2.5 + sin(4*3.5*\x r)/3.5 + sin(4*4.5*\x r)/4.5 + sin(4*5.5*\x r)/5.5} ); 

\end{tikzpicture}
</script>

Inkscape绘制+SVG插件上传

通过Inkscape绘制,注意导出的SVG时将画布调整为Resize Page to Content。上传需启用SVG Support:

多选项代码:

Alt text
Asmyptotic Behavior

标签: 暂无
最后更新:2022年 10月 2日
< 上一篇
下一篇 >
razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

文章目录
  • Tikzjax引擎
  • Inkscape绘制+SVG插件上传

渺小的思考填满了人的一生