1

I would like to add on the x axis the value for each bar that are 400, 500, 600 and 700. I don't know why the only one that appears is 400.

enter image description here

The code I used is the following

\documentclass[a4paper,twoside,12pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage{pgfplotstable}

\pgfplotsset{
    discard if/.style 2 args={
        x filter/.code={
            \ifdim\thisrow{#1} pt=#2pt
                \def\pgfmathresult{inf}
            \fi
        }
    },
    discard if not/.style 2 args={
        x filter/.code={
            \ifdim\thisrow{#1} pt=#2pt
            \else
                \def\pgfmathresult{inf}
            \fi
        }
    }
}

\begin{filecontents*}{ta.dat}
T       K
400     1
500     1.4
600     0.5
700     1.6
\end{filecontents*}

\begin{document}

\begin{tikzpicture}
    \begin{axis} [
            ymin=0,
            ybar, bar width=20, bar shift=0,
            xtick=data,
            ymajorgrids=true]
            \pgfplotsinvokeforeach{400,500,600,700}{
                \addplot+[discard if not={T}{#1}] table [x=T,y=K] {ta.dat};
            }
    \end{axis}
\end{tikzpicture}

\end{document}
Stefano
  • 1,038

0 Answers0