3

I use \shade [ball color=black!60!red] (0,0) circle (4pt); command inside tikz image to represent a vertex of a graph. Now I am using some operation where two vertices are merged. So is it possible to have a shaded ball with two sided color?

I have gone through the following link, but it is a a circle type. I need a ball type. So is it possible? Please help.

  \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}
  • 3
    Please don't post code fragments. Instead put your fragments into a compilable document that shows what you are doing. – Alan Munn Sep 27 '17 at 4:04
  • A suggestion is to try to use only cm or only pt so that you can easily automate your work by additions and subtractions of the lengths. In my answer I found the point by testing values but it could be much easier if I could use your dimensions and add or subtract some values. – koleygr Sep 27 '17 at 5:29
4

Here is an answer with semi-sphaire over your original sphaire: (The idea was from: This answer)

 \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}

Output:

enter image description here

  • Please suggest how to rotate it. It is horizontal half type. How do I make it vertical half? – G_0_pi_i_e Sep 27 '17 at 13:42
  • 1
    @G_0_pi_i_e: \shade[ball color=ffqqqq] (6.,3.18) arc (90:270:5pt); instead of the previous arc drawing. – koleygr Sep 27 '17 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.