我对 tikz 不是很熟悉,但我想画一条抛物线,带阴影(带有图案、西北线)和边界。到目前为止,我得到了这个:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\draw [->] (-3,0)--(3,0) node [right] {$x$};
\draw [->] (0,-1)--(0,6) node [below left] {$y$};
\draw [ultra thick, black] (0,0) parabola(2,5) node{$\bullet$};
\draw [densely dotted] (-2,5) -- (2,5);
\draw [ultra thick, black] (0,0) parabola(-2,5) node{$\bullet$};
\draw [pattern=north west lines] (0,0) parabola (2,5);
\draw (-0.5,-0.3) node {$(0,0)$};
\draw (0,0) node{$\bullet$};
\end{tikzpicture}
\end{document}
嗯,这不是我想要的,因为它留下了很多空白。如果能提出任何建议 - 我仍然很新,缺乏经验,我将不胜感激。
答案1
您parabola bend
还可以使用 来放置抛物线顶点。字符\bullet
不能保证居中,并且取决于字体,因此我使用circle
。
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\draw[->] (-3,0)--(3,0) node [right] {$x$};
\draw[->] (0,-1)--(0,6) node [below left] {$y$};
\draw[ultra thick, black] (-2,5) parabola bend (0,0) (2,5);
\fill (-2,5) circle[radius=2pt] (0,0) circle[radius=2pt] (2,5) circle[radius=2pt];
\draw[densely dotted, thick] (-2,5) -- (2,5);
\draw[pattern=north west lines] (-2,5) parabola bend (0,0) (2,5);
\draw (-0.5,-0.3) node {$(0,0)$};
\end{tikzpicture}
\end{document}
答案2
与使用库的 @hpekristiansen 答案(+1)有细微变化patterns.meta
:
\documentclass[tikz, border=3.141592]{standalone}
\usetikzlibrary{patterns.meta}
\begin{document}
\begin{tikzpicture}[
dot/.style = {circle, fill, node contents={},
inner sep=1.6pt, outer sep=0pt}
]
% axis
\draw[->] (-3,0.0) -- (3,0) node [below left] {$x$};
\draw[->] (0,-0.5) -- (0,6) node [below left] {$y$};
% parabola
\draw [thick,
pattern={Lines[angle=45,distance={3pt},line width=0.2pt]},
pattern color=gray]
(-2,5) parabola bend (0,0) (2,5);
\draw[densely dotted, semithick]
(-2,5) node[dot] -- (2,5) node[dot];
% coordinate origin
\path (0,0) node[below left] {(0,0)};
\end{tikzpicture}
\end{document}
编辑:删除dot
抛物线上多余的节点。