在 TikZ 中缩放圆和标准抛物线的图形

在 TikZ 中缩放圆和标准抛物线的图形

以下代码在笛卡尔平面上渲染圆弧和标准抛物线的图形。但是它太小了。如何放大显示,除了轴上的标签?(我不想使用pgfplots。)

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}



\begin{document}


\noindent \hspace*{\fill}
\begin{tikzpicture}
%An arc of a circle centered at (0, 1/2) and the standard parabola are drawn on the Cartesian plane.
\draw[fill] (0,1/2) circle (1.5pt);
\draw[blue] ($(0,1/2) +(150:1/2)$) arc (150:390:1/2);
\draw[domain={-sqrt(3)/2}:{sqrt(3)/2}] plot (\x, {\x*\x});
\draw[latex-latex] ($(-12.5pt,0) +({-1/sqrt(2)},0)$) -- ($(12.5pt,0) +({1/sqrt(2)},0)$);
\draw[latex-latex] (0,-1/2) -- ($(0,3/4) +(0,12.5pt)$);
\node[below right] at ($({1/sqrt(2)}, 0) +(12.5pt,0)$){\textit{x}};
\node[above right] at ($(0,3/4) +(0,12.5pt)$){\textit{y}};

\end{tikzpicture}
\hspace{\fill}



\end{document}

答案1

  • 我添加了scale选项。我认为scale=5在这种情况下是合适的。
  • 我不会使用您的方法来居中图形。我会使用figure并添加标题和标签。如果您不想要标题和标签,则应该使用center环境。
  • 我把 a\draw[fill]改为\fill

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=5]
%An arc of a circle centered at (0, 1/2) and the standard parabola are drawn on the Cartesian plane.
\fill (0,1/2) circle (0.3pt); % Note that it is not 1.5pt (fixed below)
\draw[blue] ($(0,1/2) +(150:1/2)$) arc (150:390:1/2);
\draw[domain={-sqrt(3)/2}:{sqrt(3)/2}] plot (\x, {\x*\x});
\draw[latex-latex] ($(-12.5pt,0) +({-1/sqrt(2)},0)$) -- ($(12.5pt,0) +({1/sqrt(2)},0)$);
\draw[latex-latex] (0,-1/2) -- ($(0,3/4) +(0,12.5pt)$);
\node[below right] at ($({1/sqrt(2)}, 0) +(12.5pt,0)$){\textit{x}};
\node[above right] at ($(0,3/4) +(0,12.5pt)$){\textit{y}};
\end{tikzpicture}
\caption{Some caption}
\label{fig:tikzfigure}
\end{figure}
\end{document}

在此处输入图片描述


或者,如果您想让图像自动调整大小\textwidth,请查看这个漂亮的tikzscale包装。

\begin{filecontents}{mypic.tikz}
\begin{tikzpicture}
%An arc of a circle centered at (0, 1/2) and the standard parabola are drawn on the Cartesian plane.
\fill (0,1/2) circle (0.3pt);
\draw[blue] ($(0,1/2) +(150:1/2)$) arc (150:390:1/2);
\draw[domain={-sqrt(3)/2}:{sqrt(3)/2}] plot (\x, {\x*\x});
\draw[latex-latex] ($(-12.5pt,0) +({-1/sqrt(2)},0)$) -- ($(12.5pt,0) +({1/sqrt(2)},0)$);
\draw[latex-latex] (0,-1/2) -- ($(0,3/4) +(0,12.5pt)$);
\node[below right] at ($({1/sqrt(2)}, 0) +(12.5pt,0)$){\textit{x}};
\node[above right] at ($(0,3/4) +(0,12.5pt)$){\textit{y}};
\end{tikzpicture}
\end{filecontents}

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\usepackage{tikzscale}
\usepackage[showframe]{geometry}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{mypic.tikz}
\caption{Some caption}
\label{fig:tikzfigure}
\end{figure}
\end{document}

在此处输入图片描述


[第一个代码改进]

我建议不要使用实心圆作为坐标。node我认为 A 更合适。另外,anode不会被缩放scale

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\tikzset{your coordinate/.style={fill=black,inner sep=0.5pt,circle}}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=5]
%An arc of a circle centered at (0, 1/2) and the standard parabola are drawn on the Cartesian plane.
\node[your coordinate] at (0,1/2) {};
\draw[blue] ($(0,1/2) +(150:1/2)$) arc (150:390:1/2);
\draw[domain={-sqrt(3)/2}:{sqrt(3)/2}] plot (\x, {\x*\x});
\draw[latex-latex] ($(-12.5pt,0) +({-1/sqrt(2)},0)$) -- ($(12.5pt,0) +({1/sqrt(2)},0)$);
\draw[latex-latex] (0,-1/2) -- ($(0,3/4) +(0,12.5pt)$);
\node[below right] at ($({1/sqrt(2)}, 0) +(12.5pt,0)$){\textit{x}};
\node[above right] at ($(0,3/4) +(0,12.5pt)$){\textit{y}};
\end{tikzpicture}
\caption{Some caption}
\label{fig:tikzfigure}
\end{figure}
\end{document}

在此处输入图片描述

您也可以(应该)将其应用于第二个代码。顺便说一句,我认为您的圆圈太小了。

答案2

如果您想要保存scale相对缩放和/或正在使用,另一个可能有用的选项transform shape是重新定义单位向量。在此示例中,这相当于焦耳五世的建议,但在上述情况下了解此选项也许会很有用。

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[x=5cm,y=5cm]
\draw[fill] (0,1/2) circle (1.5pt);
\draw[blue] ($(0,1/2) +(150:1/2)$) arc (150:390:1/2);
\draw[domain={-sqrt(3)/2}:{sqrt(3)/2}] plot (\x, {\x*\x});
\draw[latex-latex] ($(-12.5pt,0) +({-1/sqrt(2)},0)$) -- ($(12.5pt,0) +({1/sqrt(2)},0)$);
\draw[latex-latex] (0,-1/2) -- ($(0,3/4) +(0,12.5pt)$);
\node[below right] at ($({1/sqrt(2)}, 0) +(12.5pt,0)$){$x$};
\node[above right] at ($(0,3/4) +(0,12.5pt)$){$y$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容