# Add numbers to snake(box plot)

I have the following code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds,snakes}

\begin{document}

\begin{tikzpicture} [thick, framed]

\filldraw[fill=green!20] (2.85,0) rectangle (5.7,1);

\draw (4.45,0)--(4.45,1) node[above]{$\textsc{M}$};

\draw (5.7,0.5)--(11,0.5);%vandret linie til max

\draw (2.85,0.5)--(1,0.5);%vandret linie til min

\draw (11,0.39)--(11,0.61);

\draw (1,0.39)--(1,0.61);

\draw (0,-1) -- (11,-1);

\draw[snake=ticks,segment length=1cm] (0,-1) -- (11,-1);

\end{tikzpicture}

\end{document}


I would like to have numbers( like in a coordinate system) along with the line beneath the boxplot, how to do that?

I am very new with LaTeX so as basic as possible:-)

-
Welcome to TeX.SX. A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}). –  Claudio Fiandrino Aug 14 '12 at 7:12

You can use a \foreach loop to place nodes containing the tick labels.

Note that the snakes library is deprecated. Instead, you should use the decorations.pathreplacing library. The ticks are then added by setting decoration=ticks, decorate. You can combine the \draw commands for the line and the ticks into a single command by using a postaction. Specifying a postaction will draw the path a second time, using the options specified in the postaction argument. That way, if you want to change the size of your axis, you will only need to change the coordinates once.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds,decorations.pathreplacing}

\begin{document}

\begin{tikzpicture} [thick, framed]
\filldraw[fill=green!20] (2.85,0) rectangle (5.7,1);
\draw (4.45,0)--(4.45,1) node[above]{$\textsc{M}$};
\draw (5.7,0.5)--(11,0.5);%vandret linie til max
\draw (2.85,0.5)--(1,0.5);%vandret linie til min
\draw (11,0.39)--(11,0.61);
\draw (1,0.39)--(1,0.61);
\draw [
postaction={
draw,
decoration=ticks,
segment length=1cm,
decorate,
}
] (0,-1) -- (11,-1);
\foreach \tick in {0,...,11}
\node at (\tick,-1) [below=1pt] {\tick};
\end{tikzpicture}
\end{document}

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7809473872184753, "perplexity": 8768.87874345236}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-11/segments/1424936460576.24/warc/CC-MAIN-20150226074100-00135-ip-10-28-5-156.ec2.internal.warc.gz"}