tikz:用角度填充阴影颜色
目标:画一个半圆,并用线梯度填充,根据角度变化。例如,角度从θ= 0到θ=π,可以预期填充色调从红色到蓝色。
在tikz手册中( https://tikz.dev/library-shadings ),阴影模式没有我在以下方面的需求:
选项
shading =色轮
似乎仅适用于圆而不是半圆。选项
shading =色轮
在原点处呈现扭曲的颜色,而shading =色轮白色中心
填充了原点的白色区域。颜色whell
似乎并不是真正的线路分级。
因此,有什么方法可以通过角度填充线梯度填充理想的半圆?
可以看到一个类似的示例在这里,但是需要一些更改:
可以预期。是半圆而不是象限。
填充的颜色优于按角度(或其结合角度)为渐变。
我尝试了以下代码,但是梯度模式似乎并不十分明显,而起源很棘手。
\documentclass[tikz, margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
\clip (0, 0) -- (1, 0) arc [start angle=0, end angle=180, radius=1cm] -- cycle ;
\shade[shading=color wheel, shading angle=-60] (0, 0) circle (1cm) ;
\end{tikzpicture}
\end{document}
Goal: Draw a semi-circle and fill it with line-gradient color that changes according to angle. For example, with angle from θ=0 to θ=π, it is expected that the filling color shades from red to blue.
In tikz manual (https://tikz.dev/library-shadings), the shading pattern does not statisfy my need in the following aspects:
The option
shading = color wheel
seems to only applicable to a circle rather than semi-circle.The option
shading = color wheel
renders a distorted color at the origin, whileshading=color wheel white center
fills a white region at the origin.The
color whell
seems not really line-gradient.
So, is there any way to make an ideal semi-circle with line-gradient color filling by angle?
A similar example can be seen here, but some changes are needed:
It is expected to be semi-circle rather than a quadrant.
The filled color is prefered to be gradient according the angle(or its consine).
I tried the following codes, but the gradient pattern seems not quite obvious, and the origin is screwy.
\documentclass[tikz, margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
\clip (0, 0) -- (1, 0) arc [start angle=0, end angle=180, radius=1cm] -- cycle ;
\shade[shading=color wheel, shading angle=-60] (0, 0) circle (1cm) ;
\end{tikzpicture}
\end{document}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用
pgfplots
,然后您对颜色尺度的控制最多:I suggest to use
pgfplots
, then you have the most control over the colour scale: