Take the 2-minute tour ×
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.

The following code can be used to create a TikZ plot:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[%
     view={0}{90},
     scale only axis,
     width=\linewidth,
     height=0.839628\linewidth,
     xmin=40000, xmax=140000,
     ymin=2e+008, ymax=2.03e+008,
     axis on top,
     legend style={nodes=right}]
\end{axis}
\end{tikzpicture}

\end{document}

My output is this:

enter image description here

The "2" and the "0.4" overlap. How can I fix this?

share|improve this question
2  
You could specify xtick={50000,60000,70000,80000,90000,100000,110000,120000,130000,140000},. This is a bit manual, but it does work. Perhaps someone else will have a better idea –  cmhughes Mar 4 '12 at 19:15
1  
You could shift the xticklabels down a bit with xticklabel shift={.1cm} as an argument to the axis, would that be acceptable? –  Torbjørn T. Mar 4 '12 at 21:02
    
Both are good suggestions which work! Thanks! If you add them as answers we can mark this question as resolved. –  Ben Mar 4 '12 at 21:20
1  
There is another problem with this chart: values on the y-axis are apparently degenerate due to the precision formatting. Adding yticklabel style={/pgf/number format/fixed, /pgf/number format/precision=3} (cannibalised from this nabble thread) seems to fix the issue. –  Richard Terrett Mar 5 '12 at 3:54
add comment

2 Answers

up vote 6 down vote accepted

You could shift the xticklabels down a bit by adding xticklabel shift={.1cm} as an argument to the axis environment. This moves all the xticklabels away from the axis by the specified length. There is (naturally) a similar command for the y-axis, yticklabel shift={<dimension>}, as well as a command that affects all axis, ticklabel shift={<dimension>}. From section 4.14.2 Tick Alignment: Positions and Shifts in the manual (for v. 1.5.1, dated Dec 29, 2011).

Close up screenshot of the difference:

without xticklabelshiftwith ticklabelshift

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
     view={0}{90},
     scale only axis,
     width=\linewidth,
     height=0.839628\linewidth,
     xmin=40000, xmax=140000,
     ymin=2e+008, ymax=2.03e+008,
     axis on top,
     legend style={nodes=right},
     xticklabel shift={.1cm}]
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
add comment

One way is to specify your xticks so that

xtick={50000,60000,70000,80000,90000,100000,110000,120000,130000,140000}

Note that you can't do

xtick={50000,60000,...,140000}

as the numbers are too big to handle.

Ideally I would have found a solution that was less manual, but I'm usually prepared to make the effort if the end result is good :)

enter image description here

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[%
scale only axis,
width=\linewidth,
height=0.839628\linewidth,
xmin=40000, xmax=140000,
ymin=2e+008, ymax=2.03e+008,
xtick={50000,60000,70000,80000,90000,100000,110000,120000,130000,140000},
axis on top,
legend style={nodes=right}]
\end{axis}
\end{tikzpicture}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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