TikZ 中线条的颜色渐变

TikZ 中线条的颜色渐变

如果我画一条如下的线:

\documentclass[article]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,calc,shapes,arrows,snakes,shapes.geometric,patterns,fadings}
\begin{document}
\begin{tikzpicture}
\draw[very thick](0,0)--(1,0);

我怎样才能画出一条线,使线开始是红色,然后逐渐变成蓝色,我试过

\documentclass[article]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,calc,shapes,arrows,snakes,shapes.geometric,patterns,fadings}
\begin{document}
\begin{tikzpicture}
\draw[very thick,top color=red,bottom color=blue](0,0)--(1,0);

但它似乎没有任何作用,有什么建议吗?

相关内容