Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. documentclass{article}
  2.  
  3. usepackage{pgfplots}
  4.  
  5. % argument #1: any options
  6. newenvironment{customlegend}[1][]{%
  7. begingroup
  8. % inits/clears the lists (which might be populated from previous
  9. % axes):
  10. csname pgfplots@init@cleared@structuresendcsname
  11. pgfplotsset{#1}%
  12. }{%
  13. % draws the legend:
  14. csname pgfplots@createlegendendcsname
  15. endgroup
  16. }%
  17.  
  18. % makes addlegendimage available (typically only available within an
  19. % axis environment):
  20. defaddlegendimage{csname pgfplots@addlegendimageendcsname}
  21.  
  22. begin{document}
  23.  
  24. thispagestyle{empty}
  25.  
  26. begin{tikzpicture}
  27. begin{customlegend}[legend entries={$a$,$e^x$,C,$d$}]
  28. addlegendimage{red,fill=black!50!red,area legend}
  29. addlegendimage{red,fill=black!50!red,sharp plot}
  30. addlegendimage{red,fill=black!50!red,mark=*,sharp plot}
  31. addlegendimage{red,fill=black!50!red,ybar,ybar legend}
  32. end{customlegend}
  33. end{tikzpicture}
  34.  
  35. end{document}
  36.  
  37. documentclass{article}
  38. usepackage{pgfplots}
  39. begin{document}
  40.  
  41. begin{tikzpicture}
  42. begin{axis}[xmin=0,xmax=10,ymin=-5,ymax=5,name=border]
  43. end{axis}
  44.  
  45. node[below left=1mm] at (border.north east) {fbox{
  46. begin{tabular}{@{}r@{ }l@{}}
  47. raisebox{2pt}{tikz{draw[black] (0,0) -- (5mm,0);}}&black\
  48. raisebox{2pt}{tikz{draw[red] (0,0) -- (5mm,0);}}&red\
  49. raisebox{2pt}{tikz{draw[green] (0,0) -- (5mm,0);}}&green\
  50. raisebox{2pt}{tikz{draw[blue] (0,0) -- (5mm,0);}}&blue\
  51. end{tabular}}};
  52.  
  53. end{tikzpicture}
  54. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement