123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- \documentclass[varwidth=true, border=2pt]{standalone}
- \usepackage{tikz}
- \usepackage{tkz-euclide}
- \usetikzlibrary{calc,shadings}
- \usepackage{pgfplots}
- \begin{document}
- \usetkzobj{all}
- \newenvironment{customlegend}[1][]{%
- \begingroup
- % inits/clears the lists (which might be populated from previous
- % axes):
- \csname pgfplots@init@cleared@structures\endcsname
- \pgfplotsset{#1}%
- }{%
- % draws the legend:
- \csname pgfplots@createlegend\endcsname
- \endgroup
- }%
- % makes \addlegendimage available (typically only available within an
- % axis environment):
- \def\addlegendimage{\csname pgfplots@addlegendimage\endcsname}
- %%--------------------------------
- % definition to insert numbers
- \pgfkeys{/pgfplots/number in legend/.style={%
- /pgfplots/legend image code/.code={%
- \node at (0.295,-0.0225){#1};
- },%
- },
- }
- \pgfdeclarelayer{background}
- \pgfdeclarelayer{foreground}
- \pgfsetlayers{background,main,foreground}
- \begin{tikzpicture}
- \tkzSetUpPoint[shape=circle,size=10,color=black,fill=black]
- \tkzDefPoints{0/0/A, 2/0/B, 3/0.5/C, 0/3/D, 2/3/E, 3/1.5/F, 2/2/G, 1/1.5/H}
- \begin{pgfonlayer}{foreground}
- %Get intersections
- \tkzInterLL(B,H)(A,C) \tkzGetPoint{I}
- \tkzInterLL(B,F)(A,C) \tkzGetPoint{J}
- \tkzInterLL(A,G)(B,H) \tkzGetPoint{K}
- \tkzInterLL(A,G)(H,F) \tkzGetPoint{L}
- \tkzInterLL(C,G)(B,F) \tkzGetPoint{M}
- \tkzInterLL(C,G)(H,F) \tkzGetPoint{N}
- \tkzInterLL(G,D)(H,E) \tkzGetPoint{O}
- \tkzDrawPoints[color=green,fill=green](A,C,G,D)
- \tkzDrawPoints[color=blue,fill=blue](B,F,E,H)
- \tkzDrawPoints[color=red,fill=red](I,J,K,L,M,N,O)
- \end{pgfonlayer}
- \tkzDrawPolygon[blue,very thick](H,E,F,B)
- \tkzDrawSegment[blue,very thick](H,F)
- \tkzDrawPolygon[green,very thick](A,D,G,C)
- \tkzDrawSegment[green,very thick](A,G)
- \tkzDrawSegments[red,very thick](I,M I,N I,L A,H H,D L,O N,E G,E)
- % \tkzLabelPoint(A){A}
- % \tkzLabelPoint(B){B}
- % \tkzLabelPoint(C){C}
- % \tkzLabelPoint(D){D}
- % \tkzLabelPoint(E){E}
- % \tkzLabelPoint(F){F}
- % \tkzLabelPoint(G){G}
- % \tkzLabelPoint(H){H}
- % \tkzLabelPoint(I){I}
- % \tkzLabelPoint(J){J}
- % \tkzLabelPoint(K){K}
- % \tkzLabelPoint(L){L}
- % \tkzLabelPoint(M){M}
- % \tkzLabelPoint(N){N}
- % \tkzLabelPoint(O){O}
- \begin{customlegend}[
- legend entries={
- $T_1$,
- $T_2$,
- $T$
- },
- legend style={at={(4.5,3.5)},font=\footnotesize}] % <= to define position and font legend
- % the following are the "images" and numbers in the legend
- \addlegendimage{blue,very thick}
- \addlegendimage{green,very thick}
- \addlegendimage{red,very thick}
- \end{customlegend}
- \end{tikzpicture}
- \end{document}
|