2

I would like to know why the x axis partially disappears, given the following code. Is it a PDF problem? Also, is there any option to connect the midpoints automatically but not in a smooth fashion?

The code is:

\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,   
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$},
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,line join=round, smooth] 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}
3
4
+100

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$},
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}
1
  • better answer. I am deleting mine. – vrleboss May 3 '13 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.