# How can one go about drawing a sphere with a hole using pgfplots or TikZ?

I want to draw a sphere with a hole as shown below:

What I have done so far is to create an outline of the required shape in Inkscape and export to a pstricks picture.

The autogenerated code is as under

\documentclass[10pt]{article}
\usepackage{pstricks}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}
\begin{pspicture}(286.29050428,360.71140079)
{
\pscustom[linewidth=2.83464567,linecolor=black]
{
\newpath
\moveto(139.52774929,302.33545622)
\curveto(180.48641764,305.30507638)(198.90888567,270.4308578)(199.85526803,242.00794504)
\curveto(200.1155263,234.19166284)(186.99812409,224.51682819)(184.40553827,224.35110725)
\lineto(104.9497852,222.87970693)
\curveto(88.89492283,226.469763)(86.61774992,248.37367481)(89.50005543,260.40047544)
\curveto(96.87234898,283.72077654)(115.91783433,300.07697685)(139.52774929,302.33545622)
\closepath
\moveto(257.23997858,231.70812772)
\curveto(263.21746016,212.03697559)(275.69856756,194.81507449)(280.78243276,176.53051764)
\curveto(292.2452863,136.57533276)(278.2086463,87.90979575)(255.03287811,56.6111841)
\curveto(229.44509858,25.45612268)(188.65669795,4.73497622)(151.29897071,1.4335589)
\curveto(97.6206652,0.66208174)(49.36511244,27.44230221)(21.81552756,69.11809433)
\curveto(-15.19498205,130.75954693)(4.53473008,178.71026567)(30.64394457,226.55821528)
\curveto(31.47129827,272.50697496)(39.60579402,316.15887796)(77.72883024,338.38482819)
\curveto(115.85187024,360.61077843)(151.91151118,367.26575166)(193.96965921,347.94894536)
\curveto(242.3634822,326.81267827)(253.5873222,273.83813969)(257.23997858,231.70812772)
\closepath
}
}
\end{pspicture}
\end{document}


This creates a picture as shown below.

How can I shade this to create something similar to shown above? Is there any other way to achieve this using any other package like TikZ?

• yes sure! updated question accordingly. – Damitr Mar 12 '19 at 11:03

This may give you a start.

\documentclass[tikz,border=3.14mm]{standalone}
% from https://tex.stackexchange.com/a/76216/121799
\tikzset{clip even odd rule/.code={\pgfseteorule}}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\myangleA}{140}
\path (\myangleA:3) + (0,1) coordinate (aux);
\clip[clip even odd rule,draw]
([xshift=8mm,yshift=-2mm]aux)
arc(180:0:{3*cos(180-\myangleA)-0.3*(1+cos(\myangleA))-0.8})
-- ++ (0,-0.3) arc(0:-90:0.3) --
++({-3*cos(180-\myangleA)+0.6*(1+cos(\myangleA))},0)
arc(-90:-180:0.4) -- cycle
(aux)
arc(180:0:{3*cos(180-\myangleA)-0.3*(1+cos(\myangleA))})
-- ++ (0,-1) arc(180:360-140:0.3)
arc(180-\myangleA:\myangleA-360:3)
arc(\myangleA-180:0:0.3)
--  cycle  ;