如何绘制两种不同颜色的色球?

如何绘制两种不同颜色的色球?

我使用\shade [ball color=black!60!red] (0,0) circle (4pt);tikz 图像中的命令来表示图形的顶点。现在我正在使用一些合并两个顶点的操作。那么是否可以得到一个具有双面颜色的阴影球?

我经历了以下关联,但它是圆形的。我需要球形的。这样可以吗?请帮忙。

  \documentclass[10pt]{article}
  \usepackage{pgf,tikz}
  \usepackage{mathrsfs}
   \usetikzlibrary{arrows}
   \pagestyle{empty}
   \begin{document}
  \definecolor{qqqqff}{rgb}{0.,0.,1.}
  \definecolor{ffqqqq}{rgb}{1.,0.,0.}
  \begin{figure}
   \centering
   \begin{tikzpicture}[ultra thick,x=1.0cm,y=1.0cm]
   \draw (-1.,3.)-- (-1.,1.);
   \draw (1.,1.)-- (3.,1.);
   \draw (3.,1.)-- (2.,3.);
   \draw (2.,3.)-- (1.,1.);
   \draw (6.,3.)-- (5.,1.);
   \draw (5.,1.)-- (7.,1.);
   \draw (7.,1.)-- (6.,3.);
   \draw (5.99,5.02)-- (5.99,3.02);
   \draw (-1.2,3.5) node[anchor=north west] {$u$};
   \draw (1.84,3.5) node[anchor=north west] {$v$};
   \draw (6,3.5) node[anchor=north west] {$u+v$};
   \begin{scriptsize}
   \shade [ball color=ffqqqq] (-1.,3.) circle (5pt);
   \shade [ball color=ffqqqq] (-1.,1.) circle (5pt);
   \shade [ball color=qqqqff] (1.,1.) circle (5pt);
   \shade [ball color=qqqqff] (3.,1.) circle (5pt);
   \shade [ball color=qqqqff] (2.,3.) circle (5pt);
   \shade [ball color=qqqqff] (6.,3.) circle (5pt);
   \shade [ball color=qqqqff] (5.,1.) circle (5pt);
   \shade [ball color=qqqqff] (7.,1.) circle (5pt);
   \shade [ball color=ffqqqq] (5.99,5.02) circle (5pt);
   \shade [ball color=ffqqqq] (5.99,3.02) circle (5pt);
   \end{scriptsize}
   \end{tikzpicture}
   \caption{I am trying to color the vertex $u+v$ half red - half blue}
   \end{figure}

   \end{document}

答案1

以下是使用半 sphaire 来代替您原来的 sphaire 的答案:(这个想法来自:这个答案

 \documentclass[10pt]{article}
  \usepackage{pgf,tikz}
  \usepackage{mathrsfs}
   \usetikzlibrary{arrows}
   \pagestyle{empty}
   \begin{document}
  \definecolor{qqqqff}{rgb}{0.,0.,1.}
  \definecolor{ffqqqq}{rgb}{1.,0.,0.}
  \begin{figure}
   \centering
   \begin{tikzpicture}[ultra thick,x=1.0cm,y=1.0cm]
   \draw (-1.,3.)-- (-1.,1.);
   \draw (1.,1.)-- (3.,1.);
   \draw (3.,1.)-- (2.,3.);
   \draw (2.,3.)-- (1.,1.);
   \draw (6.,3.)-- (5.,1.);
   \draw (5.,1.)-- (7.,1.);
   \draw (7.,1.)-- (6.,3.);
   \draw (5.99,5.02)-- (5.99,3.02);
   \draw (-1.2,3.5) node[anchor=north west] {$u$};
   \draw (1.84,3.5) node[anchor=north west] {$v$};
   \draw (6,3.5) node[anchor=north west] {$u+v$};
   \begin{scriptsize}
   \shade [ball color=ffqqqq] (-1.,3.) circle (5pt);
   \shade [ball color=ffqqqq] (-1.,1.) circle (5pt);
   \shade [ball color=qqqqff] (1.,1.) circle (5pt);
   \shade [ball color=qqqqff] (3.,1.) circle (5pt);
   \shade [ball color=qqqqff] (2.,3.) circle (5pt);
   \shade [ball color=qqqqff] (6.,3.) circle (5pt);
   \shade [ball color=qqqqff] (5.,1.) circle (5pt);
   \shade [ball color=qqqqff] (7.,1.) circle (5pt);
   \shade [ball color=ffqqqq] (5.99,5.02) circle (5pt);
   \shade[ball color=ffqqqq] (5.82,3)  arc (180:0:5pt);
   \end{scriptsize}
   \end{tikzpicture}
   \caption{I am trying to color the vertex $u+v$ half red - half blue}
   \end{figure}

   \end{document}

输出:

在此处输入图片描述

相关内容