2

I have a circle. I wish to shade it along its latitude and longitude as follows: Along the latitude, say starting from the point A, the color gradient should decrease until the diameter CD. Similarly from the point B(using the same color as A), the color gradient should decrease until the diameter CD. On similar lines, I need to color gradient the circle along its longitude.(Starting from C to the diameter AB and from D until the diameter AB).enter image description here

\documentclass[crop,tikz,border=5mm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\fill[fill=black] (0,0) circle (1pt);
\node[] at (0.25,0.25) {O};
\node[] at (2.25,0.25) {C};
\node[] at (-2.25,0.25) {D};
\draw[dashed] (-2,0 ) -- (2,0);
\node[] at (0.25,2.25) {A};
\node[] at (0.25,-2.25) {B};
\draw[dashed] (0,2 ) -- (0,-2);
\end{tikzpicture}
\end{document} 
  • you like that shading overlaps? wit last two to cover first two? off-topic: recent version of pgfplots is 1.15 ... – Zarko Oct 15 '17 at 5:57
  • overlapping is fine. – Jerry Oct 15 '17 at 6:01
5

you nit to clarify your demand, overlapping cause that two shadings are not visible ...

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{shadings}

\begin{document}
\begin{tikzpicture}
\draw[top color=red, bottom color=white] (2,0) arc (0:180:2);
\draw[top color=white, bottom color=red] (2,0) arc (360:180:2);
\draw[left color=blue, right color=white] (0, 2) arc (90:270:2);
\draw[right color=blue, left color=white] (0,-2) arc (-90:90:2);
\fill[black] (0,0) circle (1pt) node[above right] {O};
\draw[densely dashed]
    ( 90:2) node[above] {A} -- (270:2) node[below] {B}
    (180:2) node[left]  {D} -- (  0:2) node[right] {C};
\end{tikzpicture}

\begin{tikzpicture}
\draw[top color=red, bottom color=white, semitransparent] (2,0) arc (0:180:2);
\draw[top color=white, bottom color=red, semitransparent] (2,0) arc (360:180:2);
\draw[left color=blue, right color=white, semitransparent] (0, 2) arc (90:270:2);
\draw[right color=blue, left color=white, semitransparent] (0,-2) arc (-90:90:2);
\fill[black] (0,0) circle (1pt) node[above right] {O};
\draw[densely dashed]
    ( 90:2) node[above] {A} -- (270:2) node[below] {B}
    (180:2) node[left]  {D} -- (  0:2) node[right] {C};
\end{tikzpicture}
\end{document}

second image has semitransparent shadings.

  • thanks for the help! I will use the same colors with different intensities and see how it is, as I can see overlapping causes invisibility of the shadings. – Jerry Oct 15 '17 at 6:43
  • Is it possible to use radial shading for the improvement. For example the point (1,-1) [since its a circle of radius 2] be the white region and the color gradient changes radially to black? – Jerry Oct 15 '17 at 21:01
  • see tex.stackexchange.com/questions/82425/…. maybe can help you. – Zarko Oct 15 '17 at 21:21

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.