我需要用无理数标记一个正方形。假设我有一个大小为 2 $\pi$ $\times$ 2 $\pi$ 的正方形。但想到像这样显示轴:
但是当我编写代码时,它的字体非常小,数字非常接近
\documentclass[tikz,border=0.14mm]{standalone}
\usepackage{tikz}
\begin{document}
\Huge
\begin{tikzpicture}
\draw (0,0) rectangle (2,2);
\draw[thick] (1-0.2,-0.5) node[anchor=north west] {$x$};
\draw[thick] (-0.5,1-0.3) node[anchor=south east] {$y$};
\foreach \x in {0,1/2,1,3/2,2}
\draw (\x ,0.05pt) -- (\x ,-0.05pt) node[anchor=north] {$\x$};
\foreach \y in {0,1/2,1,3/2,2}
\draw (0.05pt,\y ) -- (-0.05pt,\y ) node[anchor=east] {$\y$};
\end{tikzpicture}
\end{document}
答案1
pi
只需说即可缩放轴scale=pi
。除非添加transform shape
,否则文本不会缩放。
\documentclass[tikz,border=0.14mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=pi]
\draw (0,0) rectangle (2,2);
\draw[thick] (1-0.2,-0.5) node[anchor=north west] {$x$};
\draw[thick] (-0.5,1-0.3) node[anchor=south east] {$y$};
\foreach \x in {0,1/2,1,3/2,2}
\draw (\x ,0.05pt) -- (\x ,-0.05pt) node[anchor=north] {$\x$};
\foreach \y in {0,1/2,1,3/2,2}
\draw (0.05pt,\y ) -- (-0.05pt,\y ) node[anchor=east] {$\y$};
\draw (0,0) -- (1,1) -- (2,0);
\draw[red] (0,2) -- (1,1) -- (2,2) (0,1) -- (1,2);
\draw[red,dashed] (1,2) -- (2,1);
\node[align=center] at (0.5,1) {Fish\\ don't like\\ this island};
\node[align=center] at (1,1.5) {Fish\\ island\\ 1};
\node[align=center] at (1.5,1) {Fish\\ island\\ 2};
\end{tikzpicture}
\end{document}