Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to use legend-entry for straight line & dotted line.

\begin{figure}[htp]
{\small
\centering
\begin{tikzpicture}

\draw [color=black, fill=gray!50] ( 0.2 , 1.975 )-- ( 0.3 , 2.05 )-- ( 0.4 , 2.185 )-- ( 0.5 , 2.32 ) --( 0.5 , 2.2222 )-- ( 0.4 , 1.8 )-- ( 0.3 , 1.25 )--( 0.2 , 1.1111 )--cycle;
\draw (0.2,0) -- (10.3,0);

\draw (0.2,5.1) -- (10.3,5.1);

\draw (0.2,0)-- (0.2,5.1);

\draw (10.3,0)-- (10.3,5.1);
\draw ( 0.2 , 1.975 )-- ( 0.3 , 2.05 )-- ( 0.4 , 2.185 )-- ( 0.5 , 2.32 )-- ( 0.6 , 2.445 )-- ( 0.7 , 2.56 )-- ( 0.8 , 2.66 )-- ( 0.9 , 2.745 )-- ( 1.0 , 2.825 )-- ( 1.1 , 2.9 )-- ( 1.2 , 2.965 )-- ( 1.3 , 3.025 )-- ( 1.4 , 3.08 )-- ( 1.5 , 3.13 )-- ( 1.6 , 3.18 )-- ( 1.7 , 3.22 )-- ( 1.8 , 3.26 )-- ( 1.9 , 3.3 )-- ( 2.0 , 3.335 )-- ( 2.1 , 3.37 )-- ( 2.2 , 3.4 )-- ( 2.3 , 3.43 )-- ( 2.4 , 3.46 )-- ( 2.5 , 3.485 )-- ( 2.6 , 3.51 )-- ( 2.7 , 3.535 )-- ( 2.8 , 3.56 )-- ( 2.9 , 3.58 )-- ( 3.0 , 3.6 )-- ( 3.1 , 3.62 )-- ( 3.2 , 3.64 )-- ( 3.3 , 3.66 )-- ( 3.4 , 3.675 )-- ( 3.5 , 3.695 )-- ( 3.6 , 3.71 )-- ( 3.7 , 3.725 )-- ( 3.8 , 3.74 )-- ( 3.9 , 3.755 )-- ( 4.0 , 3.77 )-- ( 4.1 , 3.78 )-- ( 4.2 , 3.795 )--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, 2.8125 )-- ( 0.8 , 3.0247 )-- ( 0.9 , 3.2 )-- ( 1.0 , 3.3471 )-- ( 1.1 , 3.4722 )-- ( 1.2 , 3.5799 )-- ( 1.3 , 3.6735 )-- ( 1.4 , 3.7556 )-- ( 1.5 , 3.8281 )-- ( 1.6 , 3.8927 )-- ( 1.7 , 3.9506 )-- ( 1.8 , 4.0028 )-- ( 1.9 , 4.05 )-- ( 2.0 , 4.093 )-- ( 2.1 , 4.1322 )-- ( 2.2 , 4.1682 )-- ( 2.3 , 4.2014 )-- ( 2.4 , 4.232 )-- ( 2.5 , 4.2604 )-- ( 2.6 , 4.2867 )-- ( 2.7 , 4.3112 )-- ( 2.8 , 4.3341 )-- ( 2.9 , 4.3556 )-- ( 3.0 , 4.3757 )-- ( 3.1 , 4.3945 )-- ( 3.2 , 4.4123 )-- ( 3.3 , 4.4291 )-- ( 3.4 , 4.4449 )-- ( 3.5 , 4.4599 )-- ( 3.6 , 4.4741 )-- ( 3.7 , 4.4875 )-- ( 3.8 , 4.5003 )-- ( 3.9 , 4.5125 )-- ( 4.0 , 4.5241 )-- ( 4.1 , 4.5351 )-- ( 4.2 , 4.5457 )-- ( 4.3 , 4.5558 )-- ( 4.4 , 4.5654 )-- ( 4.5 , 4.5747 )-- ( 4.6 , 4.5835 )-- ( 4.7 , 4.592 )-- ( 4.8 , 4.6002 )-- ( 4.9 , 4.608 )-- ( 5.0 , 4.6155 )-- ( 5.1 , 4.6228 )-- ( 5.2 , 4.6298 )-- ( 5.3 , 4.6365 )-- ( 5.4 , 4.643 )-- ( 5.5 , 4.6492 )-- ( 5.6 , 4.6553 )-- ( 5.7 , 4.6611 )-- ( 5.8 , 4.6668 )-- ( 5.9 , 4.6722 )-- ( 6.0 , 4.6775 )-- ( 6.1 , 4.6826 )-- ( 6.2 , 4.6876 )-- ( 6.3 , 4.6924 )-- ( 6.4 , 4.697 )-- ( 6.5 , 4.7016 )-- ( 6.6 , 4.7059 )-- ( 6.7 , 4.7102 )-- ( 6.8 , 4.7143 )-- ( 6.9 , 4.7184 )-- ( 7.0 , 4.7223 )-- ( 7.1 , 4.7261 )-- ( 7.2 , 4.7298 )-- ( 7.3 , 4.7334 )-- ( 7.4 , 4.7369 )-- ( 7.5 , 4.7403 )-- ( 7.6 , 4.7436 )-- ( 7.7 , 4.7469 )-- ( 7.8 , 4.75 )-- ( 7.9 , 4.7531 )-- ( 8.0 , 4.7561 )-- ( 8.1 , 4.7591 )-- ( 8.2 , 4.7619 )-- ( 8.3 , 4.7647 )-- ( 8.4 , 4.7675 )-- ( 8.5 , 4.7701 )-- ( 8.6 , 4.7728 )-- ( 8.7 , 4.7753 )-- ( 8.8 , 4.7778 )-- ( 8.9 , 4.7802 )-- ( 9.0 , 4.7826 )-- ( 9.1 , 4.785 )-- ( 9.2 , 4.7873 )-- ( 9.3 , 4.7895 )-- ( 9.4 , 4.7917 )-- ( 9.5 , 4.7938 )-- ( 9.6 , 4.7959 )-- ( 9.7 , 4.798 )-- ( 9.8 , 4.8 )-- ( 9.9 , 4.802 )-- ( 10.0 , 4.8039 );

\draw (0.0,1.11) node{$A$};

\draw (0.65 , 2.25) node{$B$};

\draw (0.0,1.98) node{$C$};


\draw (5,-.9) node{$r \rightarrow$};

\draw (-1.6,3) node{$\delta$};

\draw (-1.6,3.32) node{$\uparrow$};

\end{tikzpicture}

}

\label{fig1}

\end{figure} 

When I use the following code, shape of the figure changes (becomes square).

\begin{tikzpicture}
\begin{axis}[ylabel=$\delta$,xlabel=$r$,  legend style={at={(0.95,0.05)},anchor=south east}]

\addplot[no marks,dotted] coordinates {( 0.2 , 1.1111 ) ( 0.3 , 1.25 ) ( 0.4 , 1.8 ) ( 0.5 , 2.2222 ) ( 0.6 , 2.551 ) ( 0.7 , 2.8125 ) ( 0.8 , 3.0247 ) ( 0.9 , 3.2 ) ( 1.0 , 3.3471 ) ( 1.1 , 3.4722 ) ( 1.2 , 3.5799 ) ( 1.3 , 3.6735 ) ( 1.4 , 3.7556 ) ( 1.5 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( 8.0 , 4.7561 ) ( 8.1 , 4.7591 ) ( 8.2 , 4.7619 ) ( 8.3 , 4.7647 ) ( 8.4 , 4.7675 ) ( 8.5 , 4.7701 ) ( 8.6 , 4.7728 ) ( 8.7 , 4.7753 ) ( 8.8 , 4.7778 ) ( 8.9 , 4.7802 ) ( 9.0 , 4.7826 ) ( 9.1 , 4.785 ) ( 9.2 , 4.7873 ) ( 9.3 , 4.7895 ) ( 9.4 , 4.7917 ) ( 9.5 , 4.7938 ) ( 9.6 , 4.7959 ) ( 9.7 , 4.798 ) ( 9.8 , 4.8 ) ( 9.9 , 4.802 ) ( 10.0 , 4.8039 )};


\addlegendentry{Style 1}
\end{axis}
\end{tikzpicture}
share|improve this question

closed as too localized by percusse, Kurt, Werner, T. Verron, Stefan Kottwitz May 24 '13 at 23:16

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
I think you don't need to be introduced to the minimal working example (MWE) concept. Plus legend is offered in pgfplots do you want to fake it in TikZ ? Also it feels like there is something wrong with Matrix (the movie) today. tex.stackexchange.com/questions/68299/… –  percusse Feb 5 '13 at 3:33
    
I do not want to use marks (0,0.2,..) on x axis and y axis. –  user12290 Feb 5 '13 at 4:12
1  
@user12290: You can just add xtick=\empty, ytick=\empty, to the options in percusse's answer to your last question to remove the ticks. –  Jake Feb 5 '13 at 6:52
2  
I suggest you to have a look to Using a pgfplots-style legend in a plain-old tikzpicture and Legend in tikzpicture. –  Claudio Fiandrino Feb 5 '13 at 8:57
1  
To set the aspect ratio to match that of your data, use the option axis equal image. –  Jake Feb 5 '13 at 20:37

Browse other questions tagged or ask your own question.