두 가지 다른 색상을 사용하여 경로가 아닌 화살표 끝 채우기

두 가지 다른 색상을 사용하여 경로가 아닌 화살표 끝 채우기

일부 화살표에 작은 문제가 있지만 해결책을 찾을 수 없는 것 같습니다. 이 질문은 다음과 다릅니다.TikZ 화살표 팁에 대해서만 채우기 색상 설정(경로 자체는 아님), 왜냐하면 OP는 전체 화살표를 한 가지 색상으로 만드는 것을 의미했기 때문입니다.

화살표 끝을 검은색으로 하고 화살표 경로를 색상으로 지정하려면 간단히 말하지만 draw=black그 반대인 색상이 있는 끝이 있는 검은색 경로가 필요합니다.

그래서 이것이 내가 얻는 것입니다:

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

그리고 이것은 내 코드입니다:

\documentclass[10pt]{article}
\usepackage[a4paper, margin=1cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{tikz}

\usetikzlibrary{arrows,backgrounds,decorations,shapes,shapes.multipart,positioning}
\pgfplotsset{compat=1.7}

\begin{document}

    \definecolor{blue}{RGB}{0,127,255}

    \tikzset{
    opera/.style={fill=white, inner sep=0pt, right=3mm, text width= 5cm,font=\footnotesize},
    tear/.style={draw=black, fill=blue, -*},.
    }

    \begin{tikzpicture}

\draw[tear] (12, 5) -- (12,4) -- (10,3) -- (10,2) node[opera] at (10,2){Not the path!};

   \end{tikzpicture}
\end{document}

코드를 최소화하기 위해 최대한 많이 제거하려고 노력했으니 사용하지 않는 패키지나 라이브러리가 보이더라도 걱정하지 마세요.

나는 옵션을 추가하는 것과 같은 가능한 해결책을 생각했지만 또는 화살표 팁을 >=stealth사용하여 색상을 설정하려고 했습니다 . 아무도 작동하지 않았습니다.o*

답변1

다음 답변은 markings및 를 기반으로 합니다 postaction.

\documentclass[10pt]{article}
\usepackage[a4paper, margin=1cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{tikz}

\usetikzlibrary{arrows,backgrounds,decorations.markings,shapes,shapes.multipart,positioning}
\pgfplotsset{compat=1.7}

\begin{document}

    \definecolor{blue}{RGB}{0,127,255}

    \tikzset{
    opera/.style={fill=white, inner sep=0pt, right=3mm, text width= 5cm,font=\footnotesize},
    tear/.style={draw=black,-, 
    decoration={markings,mark=at position 1 with {\arrow[draw=black,fill=blue]{*}}},
    postaction=decorate},.
    }

    \begin{tikzpicture}

\draw[tear] (12, 5) -- (12,4) -- (10,3) -- (10,2);

   \end{tikzpicture}
\end{document}

이는 다음을 생성합니다.
여기에 이미지 설명을 입력하세요

tear귀하의 스타일 에서 화살촉을 제거하고 decoration={markings,mark=at position 1 with {\arrow[draw=black,fill=blue]{*}}}및 를 추가했습니다 postaction=decorate. 이런 방식으로 화살표는 경로를 채우지 않고 세그먼트 끝에 장식으로 그려집니다. 또한 전체 줄이 아닌 화살촉만 덮어쓰도록 장식을 postactionwith 로 로드해야 합니다 .postaction=decorate


편집하다:이전 접근 방식은 이제 (PGF 3.0.0 출시와 함께) 더 이상 사용되지 않습니다.

\documentclass{standalone}
\usepackage{tikz}
    \usetikzlibrary{arrows.meta}
    \definecolor{myblue}{RGB}{0,127,255}

    \tikzset{
        opera/.style={
            fill=white,
            inner sep=0pt,
            right=3mm,
            text width= 5cm,
            font=\footnotesize
        },
        tear/.style={
            -{Circle[fill=myblue]}      %new code, requires arrows.meta and at least PGF 3.0.0
        },
     }
\begin{document}
\begin{tikzpicture}
    \draw[tear] (12, 5) -- (12,4) -- (10,3) -- (10,2) node[opera] {Not the path!};
\end{tikzpicture}
\end{document}

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

관련 정보