TikZ 允许你制作像这样的渐变形状
\fill [
left color=red,
right color=blue,
] (0,0) circle
故事情节也可能如此吗?
就像是
\addplot[very thick, smooth, left color=red, right color=blue]
不起作用。
答案1
您可以使用mesh
绘图样式和colormap
来实现这一点:
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:360, enlargelimits=false]
\addplot [
mesh, % Use line segments instead of one unbroken line
colormap={}{ % Define the colormap
color(0cm)=(red);
color(1cm)=(blue);
},
ultra thick,
point meta=x % Define the value that's used to determine the color
] {sin(x)};
\end{axis}
\end{tikzpicture}
\end{document}