我想重现下面的图片:
我设法想出了轴、相交虚线和彩色圆圈。我没能做到的是添加箭头、放置标签\theta
并将 2 张 tikzpicture 并排放置。以下是我根据尝试的结果输出的:
以下是我的 MWE:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=.7]
\draw [->, ultra thick, gray](0,-6)--(0,6) node[right,font=\fontsize {12}
{12}\selectfont]{Factor 1};
\draw [->,ultra thick, gray](-6,0)--(6,0) node[above,font=\fontsize {12}
{12}\selectfont]{Factor 2};
\draw[densely dashed,red] (6,-2)--(-6,2);
\draw[densely dashed,red] (-1.3,-4)--(2,5);
\foreach \Point in {(1.5,3), (.56,3.1), (1.2,3.7), (1.68,4), (.62,4.2), (1, 4.2)}{
\node[blue] at \Point {\textbullet};
}
\foreach \Point in {(3.5,-2), (5.56,-2.1), (5.2,-1.7), (3.68,-2), (4.62,-2.2), (6, -2.2),(6,-1.5)}{
\node[green] at \Point {\textbullet};
}
\end{tikzpicture}
\begin{tikzpicture}[scale=.7]
\draw [->, ultra thick, gray](0,-6)--(0,6) node[right,font=\fontsize {12}
{12}\selectfont]{Factor 1};
\draw [->,ultra thick, gray](-6,0)--(6,0) node[above,font=\fontsize {12}
{12}\selectfont]{Factor 2};
\draw[densely dashed,red] (-6,-2)--(7.3,2);
\draw[densely dashed,red] (-.7,-5.5)--(2,5);
\foreach \Point in {(1.5,3), (.56,3.1), (1.2,3.7), (1.68,4), (.62,4.2), (1, 4.2)}{
\node[blue] at \Point {\textbullet};
}
\foreach \Point in {(3.5,2), (5.56,2.1), (5.2,1.7), (3.68,2), (4.62,2.2), (6, 2.2),(6,1.5)}{
\node[green] at \Point {\textbullet};
}
\end{tikzpicture}
\end{document}
答案1
以下是一些答案,应该可以帮到您。首先,要知道还有更多方法可以实现所需的显示,并且具有不同的复杂性/灵活性。
因为您使用的是绝对定位,所以我会尝试添加尽可能少的内容:
- \theta: 它只是具有此语法的节点
\node at(0.5,1.5) {$\theta$};
。
按照您的意愿更改坐标。
to
箭头由第 74.3 节的路径绘制手动的。
\draw [thick,->] (0,6) to [out = -10, in = 120] (2,5);
在节点处分别有到达和离开的角度in
和角度。out
- 对于多个 tikzpictures,有多种方法。这是最直接的方法(在我看来,不是最好的)。只需用像这样的 resizebox 包围你的 tikz 环境:
\resizebox{0.5\linewidth}{!}{%
\begin{tikzpicture}
...
\end{tikzpicture}
}%
最后,代码如下所示:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\resizebox{0.5\linewidth}{!}{
\begin{tikzpicture}[scale=.7]
% \helpgrid
\draw [->, ultra thick, gray](0,-6)--(0,6) node[right,font=\fontsize {12}
{12}\selectfont]{Factor 1};
\draw [->,ultra thick, gray](-6,0)--(6,0) node[above,font=\fontsize {12}
{12}\selectfont]{Factor 2};
\draw[densely dashed,red] (6,-2)--(-6,2);
\draw[densely dashed,red] (-1.3,-4)--(2,5);
\foreach \Point in {(1.5,3), (.56,3.1), (1.2,3.7), (1.68,4), (.62,4.2), (1, 4.2)}{
\node[blue] at \Point {\textbullet};
}
\foreach \Point in {(3.5,-2), (5.56,-2.1), (5.2,-1.7), (3.68,-2), (4.62,-2.2), (6, -2.2),(6,-1.5)}{
\node[green] at \Point {\textbullet};
}
% to help with the placement
\draw (0,0) grid (6,6);
% adding arrows
\draw [thick,->] (0,6) to [out = -10, in = 120] (2,5);
% placing theta
\node at(0.5,1.5) {$\theta$};
\end{tikzpicture}
}
\resizebox{0.5\textwidth}{!}{
\begin{tikzpicture}[scale=.7]
\draw [->, ultra thick, gray](0,-6)--(0,6) node[right,font=\fontsize {12}
{12}\selectfont]{Factor 1};
\draw [->,ultra thick, gray](-6,0)--(6,0) node[above,font=\fontsize {12}
{12}\selectfont]{Factor 2};
\draw[densely dashed,red] (-6,-2)--(7.3,2);
\draw[densely dashed,red] (-.7,-5.5)--(2,5);
\foreach \Point in {(1.5,3), (.56,3.1), (1.2,3.7), (1.68,4), (.62,4.2), (1, 4.2)}{
\node[blue] at \Point {\textbullet};
}
\foreach \Point in {(3.5,2), (5.56,2.1), (5.2,1.7), (3.68,2), (4.62,2.2), (6, 2.2),(6,1.5)}{
\node[green] at \Point {\textbullet};
}
\end{tikzpicture}
}
\end{document}
我相信你能填空并完成你的绘图。PS:画了一个网格来帮助我定位节点。
答案2
使用 Ti钾Z 库angles
、intersections
和quotes
和arrows.meta
用于更漂亮的箭头:
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{tikz}
\usetikzlibrary{angles, arrows.meta,
intersections,
quotes}
\tikzset{
> = Straight Barb,
ANG/.style args = {#1/#2}{draw, <-, thick,
angle radius = #1,
angle eccentricity=#2},
arr/.style = {->, thick, gray}
}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.4]
\draw [arr, name path=Y]
(0,-5) -- (0,5) coordinate (y) [label=righ:Factor 1];
\draw [arr] (-6,0) -- (7,0) coordinate (x) [label=Factor 1];
%
\draw[densely dashed, red,
name path=R] (-6,2) -- (7,-2.4)
(-1.3,-4)--(2,5) coordinate (R1);
\foreach \Point in {(1.5,3), (.56,3.1), (1.2,3.7), (1.68,4), (.62,4.2), (1, 4.2)}
{
\node[blue] at \Point {\textbullet};
}
\foreach \Point in {(3.5,-2), (5.56,-2.1), (5.2,-1.7), (3.68,-2), (4.62,-2.2), (6, -2.2),(6,-1.5)}
{
\node[green] at \Point {\textbullet};
}
\draw[name intersections ={of=Y and R, by=O}]
pic [ANG=10mm/0.75, "$\theta$"] {angle=R1--O--y};
\end{tikzpicture}
\qquad
\begin{tikzpicture}[scale=0.4]
\draw [arr, name path=Y]
(0,-5) -- (0,5) coordinate (y) [label=righ:Factor 1];
\draw [arr] (-6,0) -- (7,0) coordinate (x) [label=Factor 1];
%
\draw[densely dashed, red,
name path=R] (-1,-5) -- (2,5) coordinate (R2)
(-6,-2) -- (7,2.4);
\foreach \Point in {(1.5,3), (.56,3.1), (1.2,3.7), (1.68,4), (.62,4.2), (1, 4.2)}{
\node[blue] at \Point {\textbullet};
}
\foreach \Point in {(3.5,2), (5.56,2.1), (5.2,1.7), (3.68,2), (4.62,2.2), (6, 2.2),(6,1.5)}{
\node[green] at \Point {\textbullet};
}
\draw[name intersections ={of=Y and R, by=O}]
pic [ANG=17mm/0.85, "$\theta$"] {angle=R2--O--y};
\end{tikzpicture}
\end{center}
\end{document}
(红线表示文本边框)