更新
更新 1:尝试实施 Harish Kumar 的解决方案(如下)
更新 2:添加了一个真实示例,说明我最终想要得到什么。我感觉我试图省略了很多东西。
更新3:根据下面建议的答案添加了 pstrick 标签。
更新 2:我希望得到一张像下面这样的图像,只是颜色在城市之间逐渐变化。 这就是我现在尝试实施@AndrewStacey 的建议时得到的结果这里:
原来的
为了在地图上说明一些数据,我为符合十二种条件之一的每个位置赋予了一种颜色。我希望颜色在两个位置之间缓慢过渡。在下面的示例中,三个点8
、18
和28
代表具有不同条件的三个城市。
除了在这张图片中,我希望颜色逐渐从蓝色(8 处)变为绿色(28 处),然后从绿色变为......你明白了。
我发现了很多针对两种颜色执行此操作的例子,但没有找到有关混合三种颜色的任何示例。
填充不必是圆形。最好只填充三角形内部。
有没有什么办法可以让它工作?
我在上面的例子中使用的代码:
\documentclass[svgnames, tikz]{standalone}
% Needed for Definitions
\usepackage{siunitx} % for e.g. degree celsius
\usepackage{pgfplots}
\usepackage{xcolor}
\tikzset{city/.style={
% The Shape:
circle,
inner sep=0mm,
fill=red,
minimum size=0.5mm
}}
\tikzset{fortyone/.style={
% The Shape:
circle,
inner sep=0mm,
fill=green,
opacity=0.5,
minimum size=15mm
}}
\tikzset{fortytwo/.style={
% The Shape:
circle,
inner sep=0mm,
inner color=DarkRed,
outer color=red,
opacity=0.5,
minimum size=15mm
}}
\tikzset{fortythree/.style={
% The Shape:
circle,
inner sep=0mm,
fill=blue,
opacity=0.5,
minimum size=15mm
}}
\begin{document}
\begin{tikzpicture}
% Locations on map
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\coordinate (C) at (0,1);
%%% Temporary conections
\draw (A) -- (B) -- (C) -- (A);
%%% Areas
\node at (A) [fortyone] {};
\node at (B) [fortytwo] {};
\node at (C) [fortythree] {};
%%% Cities and Labels
\node at (A) [city] {}; \node[left, font=\tiny] at (A) {28};
\node at (B) [city] {}; \node[right, font=\tiny] at (B) {18};
\node at (C) [city] {}; \node[left, font=\tiny] at (C) {8};
\end{tikzpicture}
\end{document}
更新 1: 我尝试过实现@Harish Kumar 的解决方案。对于一个三角形,它效果很好,但是随着三角形越来越多,我遇到了很多问题。
以及代码:
\documentclass[svgnames, tikz]{standalone}
% Needed for Definitions
\usepackage{siunitx} % for e.g. degree celsius
\usepackage{pgfplots}
\usepackage{xcolor}
\usetikzlibrary{shadings}
\tikzset{city/.style={
% The Shape:
circle,
inner sep=0mm,
fill=red,
minimum size=0.5mm
}}
\begin{document}
\begin{tikzpicture}
% Locations on map
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\coordinate (C) at (0,1);
\coordinate (D) at (-1,0);
\coordinate (E) at (-1,-1);
\coordinate (F) at (1,1);
\begin{scope}
\clip (A) -- (B) -- (C) -- cycle;
\shade[upper left=blue,upper right=white,
lower left=green,lower right=DarkRed]
([xshift=-0.cm]C) rectangle (B);
\end{scope}
\begin{scope}
\clip (A) -- (D) -- (C) -- cycle;
\shade[upper right=blue,upper left=white,
lower right=green,lower left=blue]
([xshift=-0.cm]C) rectangle (D);
\end{scope}
\begin{scope}
\clip (B) -- (F) -- (C) -- cycle;
\shade[upper right=DarkRed,upper left=blue,
lower right=DarkRed,lower left=green]
([xshift=-0.cm]C) rectangle (B);
\end{scope}
\begin{scope}
\clip (D) -- (E) -- (A) -- cycle;
\shade[upper right=green,upper left=blue,
lower right=DarkRed,lower left=green]
([xshift=-0.cm]E) rectangle (A);
\end{scope}
\begin{scope}
\clip (A) -- (E) -- (B) -- cycle;
\shade[upper right=DarkRed,upper left=green,
lower right=DarkRed,lower left=green]
([xshift=-0.cm]E) rectangle (B);
\end{scope}
%%% Cities and Labels
\node at (A) [city] {}; \node[below, font=\tiny] at (A) {A};
\node at (B) [city] {}; \node[right, font=\tiny] at (B) {B};
\node at (C) [city] {}; \node[above, font=\tiny] at (C) {C};
\node at (D) [city] {}; \node[left, font=\tiny] at (D) {D};
\node at (E) [city] {}; \node[left, font=\tiny] at (E) {E};
\node at (F) [city] {}; \node[above, font=\tiny] at (F) {F};
\end{tikzpicture}
\end{document}
答案1
使用 运行xelatex
。它使用 Gouraud 着色 (http://en.wikipedia.org/wiki/Gouraud_shading):
\documentclass[pstricks]{standalone}
\usepackage{pstricks-add}
\begin{document}
\psset{unit=3}
\begin{pspicture}(-1,-1)(2,2)
\pnodes(0,0){A}(1,0){B}(0,1){C}
\pscircle*[linecolor=green,opacity=0.4](A){0.75}
\pscircle*[linecolor=red,opacity=0.4](B){0.75}
\pscircle*[linecolor=blue,opacity=0.4](C){0.75}
\psGTriangle(A)(B)(C){green}{red}{blue}
\psdots[linecolor=red](A)(B)(C)
\end{pspicture}
\end{document}
第二例:
\documentclass[pstricks]{standalone}
\usepackage{pstricks-add}
\begin{document}
\psset{unit=3}
\begin{pspicture}(-0.2,-0.2)(2.25,2.25)
\pnodes(0,0){E}(1,1){A}(0,1){D}(1,2){C}(2,2){F}(2,1){B}
\psGTriangle(E)(D)(A){green}{blue}{green}
\psGTriangle(E)(A)(B){green}{green}{red}
\psGTriangle(D)(A)(C){blue}{green}{blue}
\psGTriangle(C)(A)(B){blue}{green}{red}
\psGTriangle(C)(F)(B){blue}{red}{red}
\psdots[linecolor=red](A)(B)(C)(D)(E)
\uput[-90](A){A}\uput[0](B){B}\uput[90](C){C}
\uput[180](D){D}\uput[180](E){E}
\end{pspicture}
\end{document}
答案2
以下是使用双线性插值阴影的一些粗略方法clip
:
\documentclass[svgnames, tikz]{standalone}
% Needed for Definitions
\usepackage{siunitx} % for e.g. degree celsius
\usepackage{pgfplots}
\usepackage{xcolor}
\usetikzlibrary{shadings}
\tikzset{city/.style={
% The Shape:
circle,
inner sep=0mm,
fill=red,
minimum size=0.5mm
}}
\tikzset{fortyone/.style={
% The Shape:
circle,
inner sep=0mm,
fill=green,
opacity=0.5,
minimum size=15mm
}}
\tikzset{fortytwo/.style={
% The Shape:
circle,
inner sep=0mm,
inner color=DarkRed,
outer color=red,
opacity=0.5,
minimum size=15mm
}}
\tikzset{fortythree/.style={
% The Shape:
circle,
inner sep=0mm,
fill=blue,
opacity=0.5,
minimum size=15mm
}}
\begin{document}
\begin{tikzpicture}
% Locations on map
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\coordinate (C) at (0,1);
%%% Temporary conections
%\draw (A) -- (B) -- (C) -- (A);
%%% Areas
\node at (A) [fortyone] {};
\node at (B) [fortytwo] {};
\node at (C) [fortythree] {};
%%% Cities and Labels
\node at (A) [city] {}; \node[left, font=\tiny] at (A) {28};
\node at (B) [city] {}; \node[right, font=\tiny] at (B) {18};
\node at (C) [city] {}; \node[left, font=\tiny] at (C) {8};
\begin{scope}
\clip (A) -- (B) -- (C) -- cycle;
\shade[upper left=blue,upper right=white,
lower left=green,lower right=DarkRed]
([xshift=-0.2cm]C) rectangle (B);
\end{scope}
\end{tikzpicture}
\end{document}