2

I have a plot with xticklabels defined as symbolic.

In a modified version of my plot, I want to set ymin value. When doing this, my plot is automatically updated: all x series having only points which y value is below this new ymin are removed. How can I change this behavior ?

Here is an example:

\documentclass[a4paper, landscape]{article}

\usepackage{pgfplots}
\usepackage[utf8]{inputenc}
\usepackage[margin=0.5cm]{geometry}

\pgfplotsset{compat=1.3}

\begin{document}

\centering
\begin{tikzpicture}
  \begin{axis}[
    symbolic x coords={X0, X1, X2, X3},
    xtick=data,
    grid=major,
    only marks
    ]
    \addplot coordinates {(X0,0) (X1,1) (X2,2) (X3,3)};
    \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
  \begin{axis}[
    symbolic x coords={X0, X1, X2, X3},
    xtick=data,
    grid=major,
    only marks,
    ymin=1
    ]
    \addplot coordinates {(X0,0) (X1,1) (X2,2) (X3,3)};
    \end{axis}
\end{tikzpicture}

\end{document}

Here is the result. On the second graph I would like to have X0 xtick label visible even if it's point is not.

enter image description here

3
  • 2
    Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. May 12, 2013 at 16:43
  • Do you mean that you still want a legend entry for the series even though none of its points are visible in the plot? What's the relevance of the xticklabels from table that you mentioned? Do you have a case where the x tick labels are affected by a ymin value?
    – Jake
    May 13, 2013 at 2:05
  • I added a working example to illustrate the problem. May 13, 2013 at 8:46

1 Answer 1

3

This doesn't seem to be clearly specified in the manual, but you can get the desired result by specifying xmin=X0 and enlarge x limits=true. Without the latter, X0 will lie on the y axis, i.e. there will no space to the left of X0:

Sample output

\documentclass[a4paper, landscape]{article}

\usepackage{pgfplots}
\usepackage[utf8]{inputenc}
\usepackage[margin=0.5cm]{geometry}

\pgfplotsset{compat=1.3}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[
    symbolic x coords={X0, X1, X2, X3},
    xtick=data,
    grid=major,
    only marks,
    ymin=1,
    xmin=X0,enlarge x limits=true
    ]
    \addplot coordinates {(X0,0) (X1,1) (X2,2) (X3,3)};
    \end{axis}
\end{tikzpicture}

\end{document}

In the general case you will also want to specify xmax to capture all your data points.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .