0% found this document useful (0 votes)
255 views3 pages

Pgfplots - Tikzpicture and PDF

The document is a question posted on a TeX/LaTeX forum about an issue with an axis partially disappearing in a tikzpicture plot. The asker provided code showing bars plotted along the x-axis with nodes displaying values, but the axis was interrupted. One response suggested using the 'axis on top' option to prevent bars obscuring the axis, and using 'sharp plot' to connect points without smoothing.

Uploaded by

jhorckham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
255 views3 pages

Pgfplots - Tikzpicture and PDF

The document is a question posted on a TeX/LaTeX forum about an issue with an axis partially disappearing in a tikzpicture plot. The asker provided code showing bars plotted along the x-axis with nodes displaying values, but the axis was interrupted. One response suggested using the 'axis on top' option to prevent bars obscuring the axis, and using 'sharp plot' to connect points without smoothing.

Uploaded by

jhorckham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

10/9/2015

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

Take the 2-minute tour

tikzpicture and pdf - x axis partially disappears


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}
{pgfplots} {tikz-pgf}

edited May 1 '13 at 19:27

asked May 1 '13 at 19:07

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}

answered May 3 '13 at 11:04


Jake

151k

15

472

611

better answer. I am deleting mine. vrleboss May 3 '13 at 11:19

http://tex.stackexchange.com/questions/111813/tikzpicture-and-pdf-x-axis-partially-disappears

3/3

You might also like