使用 tikz 实现平滑曲线

使用 tikz 实现平滑曲线

该图显示了催化剂对活化能的影响

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[full]{textcomp}
\usepackage[greek,italian]{babel}
\usepackage[margin=2cm,top=1cm,headheight=16pt,headsep=0.1in,heightrounded]{geometry}
\usepackage{amsmath,amssymb,amsfonts,systeme,mathtools} 
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[>=latex]
\centering
\draw[<->](0,5)node[above,rotate=90,xshift=-2cm]{Energia (kcal)}|-
(5,0)node[below,xshift=-2cm]{Coordinata di reazione}; 

\draw[violet,line width=0.4mm](0,2.5)--(1,2.5) node [below] {reagenti};
\draw[violet,line width=0.4mm](3.9,1)--(4.7,1) node [below] {prodotti};

\draw[red,line width=0.4mm] (1,2.5) to[in=180, out=0, looseness=.65] (2.35,4.5) 
                                        to[in=180, out=0, looseness=.65] (3.9,1);

\draw[blue,line width=0.4mm] (1,2.5) to[in=180, out=0, looseness=.65] (2.35,3.75) 
                                                  to[in=180, out=0, looseness=.65] (3.9,1);

\draw[dotted](1,2.5)--(6,2.5);
\draw[dotted](2.35,4.5)--(5,4.5);
\draw[dotted](2.35,3.75)--(6,3.75);
\draw[stealth-stealth](5,2.5) -- (5,4.5);
\draw[stealth-stealth](6,3.75) -- (6,2.5);

\node[inner sep=0pt, label={45:\textcolor{red}{$E_\text{a}$}}] at (5,2.5) {} ;
\node[inner sep=0pt, label={45:\textcolor{blue}{$E_\text{a}$}}] at (6,2.5) {} ;


\draw[red,line width=0.4mm] (8,3.5)--(9,3.5) node[text=black,right,yshift=1.25pt]{reazione non catalizzata};
\draw[blue,line width=0.4mm] (8,3)--(9,3) node[text=black,right,yshift=1.25pt]{reazione catalizzata};
\end{tikzpicture}

\end{document}

在此处输入图片描述

是否可以更平滑地绘制曲线?特别是尽量减少两条直线的\draw[violet,line width=0.4mm](0,2.5)--(1,2.5) node [below] {reagenti};模糊 \draw[violet,line width=0.4mm](3.9,1)--(4.7,1) node [below] {prodotti};

欢迎提出任何其他改进此图表的建议。

答案1

在等待 Tikz 特定帮助时,这里有一个替代方案元帖子,包裹在中luamplib。我相信您可以使用相同的方法通过包在 Tikz 中定义路径hobby

在此处输入图片描述

您需要使用 进行编译lualatex,并让TeX Gyre Termes 字体在您的系统上可用。

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}
\setmathfont{TeX Gyre Termes Math}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}

vardef reaction(expr w, h, d) = 
    clearxy;
    for i=0 upto 4: x[i] = w/4 * i; endfor
    x2 := 7/8 x2; % adjust peak left
    y0 = y1 = 0;
    y3 = y4 = d;
    y2 = h;
    z0 .. 1/2[z0, z1] .. controls z1 
       .. 1/8[z1, z2] .. controls z2 
       .. 1/2[z2, z3] .. controls z3 
       .. 1/2[z3, z4] .. z4
enddef;

beginfig(1);
path xx, yy;
xx = (origin -- right) scaled 300;
yy = (origin -- up) scaled 240;

path cat, dog;
cat = reaction(300, 100, -50) shifted 100 up;
dog = reaction(300, 150, -50) shifted 100.5 up;

z0 = point 0 of cat;
z1 = directionpoint right of subpath (2, 3) of cat;
z2 = directionpoint right of subpath (2, 3) of dog;

draw z0 -- (xpart point 5 of cat, y0) dashed withdots scaled 1/2;
draw z1 -- (xpart point 5 of cat, y1) dashed withdots scaled 1/2;
draw z2 -- (xpart point 4 of cat, y2) dashed withdots scaled 1/2;

path E[]; 
E1 = (xpart point 4 of cat, y2) -- (xpart point 4 of cat, y0); 
E2 = (xpart point 5 of cat, y1) -- (xpart point 5 of cat, y0); 
drawdblarrow E1; 
drawdblarrow E2; 

drawoptions(withcolor 2/3 red);
label.lft("$E_a$", point 1/2 of E1);
draw dog;
label.ulft("\begin{tabular}{c}reazione non\\catalizzata\end{tabular}", point 2.3 of dog);

drawoptions(withcolor 3/4 blue);
label.lft("$E_a$", point 1/2 of E2);
draw cat;
label("\begin{tabular}{c}reazione\\catalizzata\end{tabular}", z1 shifted 28 down);

drawoptions();

% show the points along the path...
% for i=0 upto length cat: draw fullcircle scaled 3 shifted point i of cat; endfor

drawarrow xx; label.llft("Coordinata di reazione", point 1 of xx);
drawarrow yy; label.llft(textext("Energia (kcal)") rotated 90, point 1 of yy);

label.lrt("reagenti", point 0 of cat);
label.llft("prodotti", point 5 of cat);

endfig;
\end{mplibcode}
\end{document}

相关内容