我想要变换标准坐标系,即其基向量为(1,0)
和(0,1)
:
\documentclass[a4paper, 12pt]{report}
\usepackage{fullpage}[1cm]
\usepackage{tikz}
\usepackage{pdfpages}
\begin{document}
\begin{tikzpicture}[scale=3]
\def \xLabel {$X$};
\def \yLabel {$Y$};
\draw[step=.2cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\end{tikzpicture}
\end{document}
到具有基础的新坐标系(1,-0.5)
和(-0.5,1)
(例如)
非常感谢 !!
答案1
您可以使用 重新定义单位向量x={(1,-0.5)}, y={(-0.5,1)}
。不幸的是,该grid
命令没有考虑这些单位向量,因此您必须“手动”绘制网格线:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage{pdfpages}
\begin{document}
\begin{tikzpicture}[scale=3, x={(1,-0.5)}, y={(-0.5,1)}]
\def \xLabel {$X$};
\def \yLabel {$Y$};
\begin{scope}{very thin, gray}
\foreach \x in {-1.5,-1,...,1.5}{
\draw (\x,-1.5) -- (\x,1.5);
}
\foreach \y in {-1.5,-1,...,1.5}{
\draw (-1.5,\y) -- (1.5,\y);
}
\end{scope}
\draw [very thick, cyan!80!black] (-1.5,0) -- (1.5,0);
\draw [very thick, cyan!80!black] (0,-1.5) -- (0,1.5);
\end{tikzpicture}
\end{document}
答案2
您可以使用命令来应用转换\pgftransformcm
。该grid
命令在此条件下有效。
代码:
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [very thin,gray!40,dashed] (-3,-3) grid (3,3);
%Specify the transformation matrix and the center point
\pgftransformcm{1}{-0.5}{-0.5}{1}{\pgfpoint{0}{0}}
\draw [black!60] (-3,-3) grid (3,3);
\draw [thick,red,<->] (3.5,0) node [above] {$x$} -- (0,0) -- (0,3.5) node [right] {$y$};
\end{tikzpicture}
\end{document}
这是另一个例子:绘制格点和矢量