第一张图片是我画出来的,但我想让它看起来像第二张图片。我不知道如何去除椭圆的顶部。
以下是第一张图片的代码:
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.4444444444444444cm,y=0.47619047619047616cm]
\begin{axis}[
x=0.4444444444444444cm,y=0.47619047619047616cm,
axis lines=middle,
xmin=-9.0,
xmax=9.0,
ymin=-1.5,
ymax=9.0,
xtick={-8.0,-6.0,...,8.0},
ytick={-0.0,2.0,...,8.0},]
\clip(-9.,-1.5) rectangle (9.,9.);
\fill[line width=0.8pt,fill=black,fill opacity=0.4000000059604645] (-5.199690989913828,1.960131022173449) -- (-5.2,0.) -- (5.2,0.) -- (5.200132906169648,1.777484743917159) -- (5.200146577573657,1.9603258574417475) -- (4.894074114340027,1.8358240186682537) -- (4.383736317446814,1.6540003026338357) -- (3.856667569065835,1.4954987779387272) -- (3.3057923380648537,1.3574824290886491) -- (2.3783912799393305,1.1808621745376695) -- (1.255093854183623,1.0495335902835947) -- (0.3914055491874345,1.0047903153881497) -- (-0.3005995430058771,1.0028247500658463) -- (-1.3050347730614216,1.0535812360729975) -- (-2.5429095834588207,1.2074543229397592) -- (-3.5252600258333797,1.4092987540641437) -- (-4.4555061691745905,1.6777844449657104) -- cycle;
\draw [rotate around={0.:(0.,5.)},line width=1.2pt] (0.,5.) ellipse (3.5555555555555554cm and 1.9047619047619047cm);
\draw [line width=1.2pt,dash pattern=on 3pt off 3pt] (-6.093216873727635,7.591944643010381)-- (6.027793299628012,7.629910071511935);
\draw [line width=1.2pt] (-5.199690989913828,1.960131022173449)-- (-5.2,0.);
\draw [line width=1.2pt] (5.2,0.)-- (5.200146577573657,1.9603258574417475);
\draw (-1.0689909579527075,-0.05725192695312553) node[anchor=north west] {$\textbf{O}$};
\end{axis}
\end{tikzpicture}
答案1
像这样:
代码(注意:不同行的顺序非常重要!):
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\draw[fill=gray] (-1.2,0) rectangle (1.2,1.2);
\begin{scope}
\clip (-2.2,-.5) rectangle (2.2,1.5);
\filldraw[fill=white,draw=blue,line width=2pt,opacity=1] (0,1) ellipse(1.6 and .8);
\end{scope}
\draw[-latex] (-2,0) -- (2.2,0) node[right] {$x$}; % x-axis
\draw[-latex] (0,-.5) -- (0,2.2) node[above] {$y$}; % y-axis
\node at (-.2,-.2) () {$O$}
\draw[dashed] (-1.2,1.5)--(1.2,1.5);
\end{tikzpicture}
\end{document}
答案2
极坐标在这里是你的朋友。
第一条路径通过仅绘制椭圆的下半部分(从角度 −135° 到角度 −45°)和其下方的框来绘制灰色区域。
第二部分绘制整个椭圆段 [从角度 30° 到 (-180-30)°] 但我们将保存坐标中的起点和终点,以便第三条路径可以使用它们在它们之间绘制虚线。
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[thick, x radius=3, y radius=2, >=Stealth, line cap=round]
\draw[fill=lightgray, near start]
(-135:3 and 2)
arc[start angle=-135, end angle=-45]
-- ++(down:1)
-| coordinate (O)
node[below left] {$O$} cycle;
\draw (30:3 and 2) coordinate (start)
arc[start angle=30, endangle=-180-30] coordinate (end);
\draw[dashed] (start) -- (end);
\path[->] ([shift=(down: .5)]O) edge node[at end, right] {$y$} ++( up:5)
([shift=(left:4) ]O) edge node[at end, below] {$x$} ++(right:8);
\end{tikzpicture}
\end{document}
输出
答案3
这是我使用新 tkz-elements 包进行的测试。我概括了这种情况。这里的椭圆由其两个焦点和顶点(椭圆的东边)定义,但它可以用另外两种方式定义。虚线段的端点是使用方法确定的point
,该方法通过在 0 到 2ft 之间改变角度来给出椭圆上的一个点。
然后对象椭圆具有属性,对于使用 TikZ 或 tkz-euclide 绘制它很有用;它与 Rx、Ry 和斜率有关
% !TEX TS-program = lualatex
\documentclass{standalone}
\usepackage{tkz-euclide}
\usepackage{tkz-elements}
\begin{document}
\begin{tkzelements}
z.F1 = point: new (-1 , 4)
z.F2 = point: new (3 , 0)
L.F1F2 = line : new (z.F1,z.F2)
z.V = L.F1F2: point (1.2)
E = ellipse: foci (z.F1,z.F2,z.V)
z.a = E : point (math.pi/4)
z.b = E : point (3*math.pi/4)
L.ab = line : new (z.b,z.a)
z.c = L.ab : equilateral ().pc
z.C = E.center
a = E.Rx
b = E.Ry
slope = math.deg(E.slope)
set_lua_to_tex {'a','b','slope'}
\end{tkzelements}
\begin{tikzpicture}
\tkzGetNodes
\tkzInit[xmin=-3,ymin=-3,xmax=7,ymax=7]
\tkzClip
\begin{scope}
\tkzClipCircle[out](c,a)
\tkzDrawEllipse[blue](C,\a,\b,\slope)
\end{scope}
\tkzDrawSegment[dashed](a,b)
\tkzDrawPoints(C,V,F1,F2,a,b)
\tkzLabelPoints(C,V,F1,F2)
\end{tikzpicture}
\end{document}