Pgfplots - Tikzpicture and PDF
Pgfplots - Tikzpicture and PDF
pgfplots - tikzpicture and pdf - x axis partially disappears - TeX - LaTeX Stack Exchange
sign up
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.
log in
tour
help
http://tex.stackexchange.com/questions/111813/tikzpicture-and-pdf-x-axis-partially-disappears
1/3
10/9/2015
pgfplots - tikzpicture and pdf - x axis partially disappears - TeX - LaTeX Stack Exchange
Werner
267k
23
525
883
user30009
11
Try remove [white, fill white] from the first addplot Holene May 1 '13 at 19:13
Welcome to TeX.sx! texenthusiast May 1 '13 at 20:43
It looks like you've got two separate accounts, which means you cannot edit your original post or
leave comments. The StackExchange staff can merge them together for you. Werner May 1 '13 at
23:23
1 Answer
The axis line is interrupted because you're drawing two bars with zero height on top
of it. To fix this, one way is to say axis on top in the axis options. This will also
make sure that the green bars aren't drawn on top of the axis.
It looks like you're using those empty bars only to correct the spacing. Instead of
doing that, I would recommend using the enlarge x limits key to add extra space
on the left and right of the axis.
To draw a plot consisting of straight line segments, use sharp plot:
\documentclass[landscape]{article}
\usepackage{etex}
\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage{tikz}
\usetikzlibrary{backgrounds,fadings}
\begin{document}
\begin{tikzpicture}%[show background grid]
\tikzstyle{every node}=[font=\scriptsize]
\begin{axis}[/tikz/ybar,
ybar legend,
xtick align=outside,
ymin=0,
axis y line*=left,
bar width=1.5cm,
axis x line*=left,
nodes near coords= {
\pgfmathfloattofixed{\pgfplotspointmeta}
\num[
scientific-notation = fixed,
fixed-exponent = 0,
round-mode = places,
round-precision = 2,
exponent-product=\cdot
]{\pgfmathresult}},
enlarge x limits=false,
grid=none,
axis on top,
height=6cm,
title={},
xlabel={Intervalos de Clase},
ylabel=\rotatebox{-90}{$F_{i}$},
symbolic x coords={$<11.5$,$11.5$,$14.5$,$17.5$,$20.5$,$23.5$,$>23.5$},
http://tex.stackexchange.com/questions/111813/tikzpicture-and-pdf-x-axis-partially-disappears
2/3
10/9/2015
pgfplots - tikzpicture and pdf - x axis partially disappears - TeX - LaTeX Stack Exchange
xtick={$11.5$,$14.5$,$17.5$,$20.5$,$23.5$},
minor x tick num=1,
width=\textwidth]
\addplot[white,fill=white] coordinates {($<11.5$,0) ($>23.5$,0)};
\addplot[green!80!black,fill=green!40!white] coordinates {($11.5$,0.32)($14.5$,0.56)
($17.5$,0.64) ($20.5$,0.76) ($23.5$,1.00)};
\addplot[thick,color=blue, sharp plot] coordinates {($11.5$,0.32) ($14.5$,0.56)
($17.5$,0.64) ($20.5$,0.76) ($23.5$,1.00)};
\legend{}
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}[overlay]
\node[above] (red) at (0.8,2) {\footnotesize\textcolor{magenta}{Ojiva}};
\node (reddot) at (4.1,3.0) {};
\path[->, color=magenta, line width=0.75] (red) edge [out = 50, in = 145] (reddot);
\node[right] (gre) at (11.5,2.75) {\footnotesize\textcolor{cyan}{Histograma}};
\node (gredot) at (10,2.9) {};
\path[->, color=cyan, line width=0.75] (gre) edge [out = 160, in = 45] (gredot);
\end{tikzpicture}
\end{document}
151k
15
472
611
http://tex.stackexchange.com/questions/111813/tikzpicture-and-pdf-x-axis-partially-disappears
3/3