Tikz에서 이 플롯을 그립니다(음수 축 포함).

Tikz에서 이 플롯을 그립니다(음수 축 포함).

tikz를 사용하여 다음 그림을 생성하려고 합니다.

여기에 이미지 설명을 입력하세요

그러나 최선을 다한 결과 다음과 같은 결과가 나왔습니다(내가 원하는 것은 아닙니다).

여기에 이미지 설명을 입력하세요

여기에 MWE가 있습니다(다른 텍스트가 있지만 이것이 질문의 요점은 아닙니다).

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fit, calc, matrix, positioning, arrows, intersections, through, backgrounds, patterns}

\begin{document}
\begin{figure}[!htb]
\centering
\begin{tikzpicture}[my plot/.style={thick, smooth, samples=100, domain=0:1}, my grid/.style={densely dotted,opacity=0.5, every node/.style={black,opacity=1}}, my axis/.style={latex-latex},scale=0.75]
\coordinate (start plot) at (0,{(0)});
\coordinate (end plot) at (4,{(4)});
\draw[my axis] ([shift={(-0cm,0cm)}]start plot |- end plot) node[above] {$h_2$} |- node[coordinate](origin){} ([shift={(0cm,-0cm)}]start plot -| end plot) node[right] {$h_1$};
\def\x{0.5}\def\y{4}\def\p{0.55}
\coordinate (Ux) at (4.5,{(0)});
\coordinate (Uy) at (0,{(1.5)});
\coordinate (Ua) at (0,{(6)});
\coordinate (Ub) at (6,{(0)});
\coordinate (Uc) at (3,{(0)});
\coordinate (Ud) at (0,{(3)});
\coordinate (Ue) at (1.5,{(0)});
\coordinate (Uf) at (0,{(4.5)});
\coordinate (Ug) at (0,{(0)});
\coordinate (Uh) at (4.5,{(4.5)});
\coordinate (Ui) at (2,{(2)});
\coordinate (Uj) at (1.5,{(1.5)});
\coordinate (Uk) at (3,{(3)});
\coordinate (Ul) at (1.5,{(4)});
\coordinate (Um) at (4,{(1.5)});
\draw[my grid] (Uy) |- node[left,font=\scriptsize]{$1$} cycle;
\draw[my grid] (Uc) |- node[below,font=\scriptsize]{$2$} cycle;
\draw[my grid] (Ud) |- node[left,font=\scriptsize]{$2$} cycle;
\draw[my grid] (Ue) |- node[below,font=\scriptsize]{$1$} cycle;
\draw[fill] (Ug) circle (2pt);
\draw[fill] (Uj) circle (2pt);
\draw[fill] (Uk) circle (2pt);
\node [below] at (Ug) {\footnotesize{$h(T,R)=H(B,L)$}};
\node [below, xshift=10pt] at (Uj) {\footnotesize{$h(T,L)$}};
\node [right] at (Uk) {\footnotesize{$h(B,R)$}};
\node [left] at (Uj) {\footnotesize{$C(G)$}};
\draw[-] (Uj) -- (Ug);
\draw[-] (Uk) -- (Uj);
\draw[-] (Uj) -- (Ul);
\draw[-] (Uj) -- (Um);
\end{tikzpicture}
\end{document}

여기서 가장 큰 문제는 음수 x 및 y 축으로 플롯을 얻는 방법에 대한 단서가 문자 그대로 없다는 것입니다. 누구든지 내가 원하는 결과를 얻을 수 있도록 도와줄 수 있나요?

다들 감사 해요!

답변1

다음은 비슷한 그림이 포함된 작은 코드입니다. 이름을 모르기 때문에 글꼴을 변경하지 않았습니다.

\documentclass{article}

\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}[scale = 2]
    % axis drawing
    \draw [->] (0,-2) -- (0,2);
    \draw [->] (-2,0) -- (2,0);

    \node[below] at (-1,0) {$-1$};
    \node[below] at (1,0) {$1$};
    \node[left] at (0,-1) {$-1$};
    \node[left] at (0,1) {$1$};
    \node[right] at (2,0) {$h_1$};
    \node[above] at (0,2) {$h_2$};

    % diagonal drawing
    \draw[thick] (-1,1) -- (1,-1);
    \draw[fill] (-1,1) circle [radius=0.05];
    \draw[fill] (1,-1) circle [radius=0.05];

    \node[below right] at (1,-1) {$h(H,H) = h(T,T)$};
    \node[above left] at (-1,1) {$h(T,H) = h(H,T)$};
    \node[below] at (-1,0.7) {$C(G)$};

    % axis 2 drawing
    \draw (1,2.1) -- (1,1) -- (2.1,1);
    \node[right] at (2.1,1) {$R_2=1$};
    \node[above] at (1,2.1) {$R_1=1$};

    \end{tikzpicture}

\end{document}

그래픽 드로잉

답변2

나는 당신의 MWE에서 길을 잃었다는 것을 고백해야 합니다. 결과적으로 나는 당신이 이미지 요소의 위치를 ​​지정할 때 오류를 범하는 부분을 찾지 못했습니다. 오히려 주어진 이미지를 처음부터 다시 그립니다(큰 문제는 아니며 오히려 간단합니다).

\documentclass [tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows}
\usepackage{sansmath}

\begin{document}
    \begin{tikzpicture}[
every node/.style = {font=\sansmath, color=blue!70!black}
TL/.append style = {font=\sffamily\scriptsize}% TL: Tick Labels
                        ]
% axis
\draw[->] (-3,0)   -- (3,0) node[right] {$h_1$};
\draw[->] (0,-2.5) -- (0,3) node[above] {$h_2$};
% tick
\foreach \i in {-2,-1,1,2}
    \draw (\i,2pt) -- ++ (0,-4pt)   node[TL,below] {\i}
          (2pt,\i) -- ++ (-4pt,0)   node[TL, left] {\i};
% curve (line)
\draw[thick,*-*]    (-1,1) node[left]  {$h(T,H)=h(H,T)$}
                --  (1,-1) node[right] {$h(H,H)=h(T,T)$};       
% R coordinate system?
\draw   (1,2) node[above]  {$R_1=1$}
    |-  (2,1) node[right]  {$R_2=1$};
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보