Grouped bar chart in pgfplots from file selecting certain rows












1















I want to create a bar chart from the following data, using the column difficulty to select rows from kappa.



I hope to avoid having to type out the contents of the csv file in a series of add plot statements



Can one use the meta variable as follows?



begin{axis}[ybar]

begin{tikzpicture}
begin{axis}[ybar,ymajorgrids, tick align=inside,
major grid style={draw=white},axis x line*=bottom,
axis y line*=right,symbolic x coords={
Human-Human,Human-Tak,Human-Gold Standard, Tak-Gold Standard},]
addplot table[x=type, y=kappa, meta=difficulty=0]{combined-kappas.csv};
addplot table[x=type, y=kappa, meta=difficulty=1]{combined-kappas.csv};
addplot table[x=type, y=kappa, meta=difficulty=2]{combined-kappas.csv};
end{axis}


CSV Data:



r1,r2,type,kappa,difficulty
Alex,Tak,Human-Human,0.9878019029031471,0
Alex,Inferred,Human-Tak,0.6199032480995161,0
Alex,Intended,Human-Gold Standard,1,0
Tak,Inferred,Human-Tak,0.6081143384047948,0
Tak,Intended,Human-Gold Standard,0.9878019029031471,0
Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
Alex,Tak,Human-Human, 0.791208791208791,1
Alex,Inferred,Human-Tak,0.306901088386556,1
Alex,Intended,Human-Gold Standard,0.844389844389844,1
Tak,Inferred,Human-Tak,0.245305729417429,1
Tak,Intended,Human-Gold Standard,0.757327238504975,1
Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
Alex,Tak,Human-Human,0.547137761168677,2
Alex,Inferred,Human-Tak,0.137205030380104,2
Alex,Intended,Human-Gold Standard,0.262046204620462,2
Tak,Inferred,Human-Tak,0.137288621381485,2
Tak,Intended,Human-Gold Standard,0.280682000965096,2
Intended,Inferred,Tak-Gold Standard,0.097688926697859,2


Intended output:
enter image description here










share|improve this question


















  • 1





    So you are searching for something similar to tex.stackexchange.com/a/352667/95441?

    – Stefan Pinnow
    4 hours ago











  • @mac389 Please add a compilable snippet.

    – Raaja
    4 hours ago











  • @StefanPinnow That example close. It selects single rows. It doesn't select multiple rows based on a column value. I like the loop.

    – mac389
    2 hours ago


















1















I want to create a bar chart from the following data, using the column difficulty to select rows from kappa.



I hope to avoid having to type out the contents of the csv file in a series of add plot statements



Can one use the meta variable as follows?



begin{axis}[ybar]

begin{tikzpicture}
begin{axis}[ybar,ymajorgrids, tick align=inside,
major grid style={draw=white},axis x line*=bottom,
axis y line*=right,symbolic x coords={
Human-Human,Human-Tak,Human-Gold Standard, Tak-Gold Standard},]
addplot table[x=type, y=kappa, meta=difficulty=0]{combined-kappas.csv};
addplot table[x=type, y=kappa, meta=difficulty=1]{combined-kappas.csv};
addplot table[x=type, y=kappa, meta=difficulty=2]{combined-kappas.csv};
end{axis}


CSV Data:



r1,r2,type,kappa,difficulty
Alex,Tak,Human-Human,0.9878019029031471,0
Alex,Inferred,Human-Tak,0.6199032480995161,0
Alex,Intended,Human-Gold Standard,1,0
Tak,Inferred,Human-Tak,0.6081143384047948,0
Tak,Intended,Human-Gold Standard,0.9878019029031471,0
Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
Alex,Tak,Human-Human, 0.791208791208791,1
Alex,Inferred,Human-Tak,0.306901088386556,1
Alex,Intended,Human-Gold Standard,0.844389844389844,1
Tak,Inferred,Human-Tak,0.245305729417429,1
Tak,Intended,Human-Gold Standard,0.757327238504975,1
Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
Alex,Tak,Human-Human,0.547137761168677,2
Alex,Inferred,Human-Tak,0.137205030380104,2
Alex,Intended,Human-Gold Standard,0.262046204620462,2
Tak,Inferred,Human-Tak,0.137288621381485,2
Tak,Intended,Human-Gold Standard,0.280682000965096,2
Intended,Inferred,Tak-Gold Standard,0.097688926697859,2


Intended output:
enter image description here










share|improve this question


















  • 1





    So you are searching for something similar to tex.stackexchange.com/a/352667/95441?

    – Stefan Pinnow
    4 hours ago











  • @mac389 Please add a compilable snippet.

    – Raaja
    4 hours ago











  • @StefanPinnow That example close. It selects single rows. It doesn't select multiple rows based on a column value. I like the loop.

    – mac389
    2 hours ago
















1












1








1








I want to create a bar chart from the following data, using the column difficulty to select rows from kappa.



I hope to avoid having to type out the contents of the csv file in a series of add plot statements



Can one use the meta variable as follows?



begin{axis}[ybar]

begin{tikzpicture}
begin{axis}[ybar,ymajorgrids, tick align=inside,
major grid style={draw=white},axis x line*=bottom,
axis y line*=right,symbolic x coords={
Human-Human,Human-Tak,Human-Gold Standard, Tak-Gold Standard},]
addplot table[x=type, y=kappa, meta=difficulty=0]{combined-kappas.csv};
addplot table[x=type, y=kappa, meta=difficulty=1]{combined-kappas.csv};
addplot table[x=type, y=kappa, meta=difficulty=2]{combined-kappas.csv};
end{axis}


CSV Data:



r1,r2,type,kappa,difficulty
Alex,Tak,Human-Human,0.9878019029031471,0
Alex,Inferred,Human-Tak,0.6199032480995161,0
Alex,Intended,Human-Gold Standard,1,0
Tak,Inferred,Human-Tak,0.6081143384047948,0
Tak,Intended,Human-Gold Standard,0.9878019029031471,0
Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
Alex,Tak,Human-Human, 0.791208791208791,1
Alex,Inferred,Human-Tak,0.306901088386556,1
Alex,Intended,Human-Gold Standard,0.844389844389844,1
Tak,Inferred,Human-Tak,0.245305729417429,1
Tak,Intended,Human-Gold Standard,0.757327238504975,1
Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
Alex,Tak,Human-Human,0.547137761168677,2
Alex,Inferred,Human-Tak,0.137205030380104,2
Alex,Intended,Human-Gold Standard,0.262046204620462,2
Tak,Inferred,Human-Tak,0.137288621381485,2
Tak,Intended,Human-Gold Standard,0.280682000965096,2
Intended,Inferred,Tak-Gold Standard,0.097688926697859,2


Intended output:
enter image description here










share|improve this question














I want to create a bar chart from the following data, using the column difficulty to select rows from kappa.



I hope to avoid having to type out the contents of the csv file in a series of add plot statements



Can one use the meta variable as follows?



begin{axis}[ybar]

begin{tikzpicture}
begin{axis}[ybar,ymajorgrids, tick align=inside,
major grid style={draw=white},axis x line*=bottom,
axis y line*=right,symbolic x coords={
Human-Human,Human-Tak,Human-Gold Standard, Tak-Gold Standard},]
addplot table[x=type, y=kappa, meta=difficulty=0]{combined-kappas.csv};
addplot table[x=type, y=kappa, meta=difficulty=1]{combined-kappas.csv};
addplot table[x=type, y=kappa, meta=difficulty=2]{combined-kappas.csv};
end{axis}


CSV Data:



r1,r2,type,kappa,difficulty
Alex,Tak,Human-Human,0.9878019029031471,0
Alex,Inferred,Human-Tak,0.6199032480995161,0
Alex,Intended,Human-Gold Standard,1,0
Tak,Inferred,Human-Tak,0.6081143384047948,0
Tak,Intended,Human-Gold Standard,0.9878019029031471,0
Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
Alex,Tak,Human-Human, 0.791208791208791,1
Alex,Inferred,Human-Tak,0.306901088386556,1
Alex,Intended,Human-Gold Standard,0.844389844389844,1
Tak,Inferred,Human-Tak,0.245305729417429,1
Tak,Intended,Human-Gold Standard,0.757327238504975,1
Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
Alex,Tak,Human-Human,0.547137761168677,2
Alex,Inferred,Human-Tak,0.137205030380104,2
Alex,Intended,Human-Gold Standard,0.262046204620462,2
Tak,Inferred,Human-Tak,0.137288621381485,2
Tak,Intended,Human-Gold Standard,0.280682000965096,2
Intended,Inferred,Tak-Gold Standard,0.097688926697859,2


Intended output:
enter image description here







pgfplots pgfplotstable graphs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 4 hours ago









mac389mac389

434314




434314








  • 1





    So you are searching for something similar to tex.stackexchange.com/a/352667/95441?

    – Stefan Pinnow
    4 hours ago











  • @mac389 Please add a compilable snippet.

    – Raaja
    4 hours ago











  • @StefanPinnow That example close. It selects single rows. It doesn't select multiple rows based on a column value. I like the loop.

    – mac389
    2 hours ago
















  • 1





    So you are searching for something similar to tex.stackexchange.com/a/352667/95441?

    – Stefan Pinnow
    4 hours ago











  • @mac389 Please add a compilable snippet.

    – Raaja
    4 hours ago











  • @StefanPinnow That example close. It selects single rows. It doesn't select multiple rows based on a column value. I like the loop.

    – mac389
    2 hours ago










1




1





So you are searching for something similar to tex.stackexchange.com/a/352667/95441?

– Stefan Pinnow
4 hours ago





So you are searching for something similar to tex.stackexchange.com/a/352667/95441?

– Stefan Pinnow
4 hours ago













@mac389 Please add a compilable snippet.

– Raaja
4 hours ago





@mac389 Please add a compilable snippet.

– Raaja
4 hours ago













@StefanPinnow That example close. It selects single rows. It doesn't select multiple rows based on a column value. I like the loop.

– mac389
2 hours ago







@StefanPinnow That example close. It selects single rows. It doesn't select multiple rows based on a column value. I like the loop.

– mac389
2 hours ago












1 Answer
1






active

oldest

votes


















0














To answer to your comment below the question:

I think the linked answer in my comment is what you are searching for. But there is one remaining problem that is, that you have multiple entries for one bar sometimes which results in multiple bars plotted. In your image there is some kind of error bar given to the bars.



The error bars can also be given to bars, but of course for that you need to modify your CSV file accordingly.



(Please note that this answer is just to prove that this in principle is what you are searching for and thus the resulting image does not look very nice.)



% used PGFPlots v1.16
begin{filecontents*}{combined-kappas.csv}
r1,r2,type,kappa,difficulty
Alex,Tak,Human-Human,0.9878019029031471,0
Alex,Inferred,Human-Tak,0.6199032480995161,0
Alex,Intended,Human-Gold Standard,1,0
Tak,Inferred,Human-Tak,0.6081143384047948,0
Tak,Intended,Human-Gold Standard,0.9878019029031471,0
Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
Alex,Tak,Human-Human, 0.791208791208791,1
Alex,Inferred,Human-Tak,0.306901088386556,1
Alex,Intended,Human-Gold Standard,0.844389844389844,1
Tak,Inferred,Human-Tak,0.245305729417429,1
Tak,Intended,Human-Gold Standard,0.757327238504975,1
Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
Alex,Tak,Human-Human,0.547137761168677,2
Alex,Inferred,Human-Tak,0.137205030380104,2
Alex,Intended,Human-Gold Standard,0.262046204620462,2
Tak,Inferred,Human-Tak,0.137288621381485,2
Tak,Intended,Human-Gold Standard,0.280682000965096,2
Intended,Inferred,Tak-Gold Standard,0.097688926697859,2
end{filecontents*}
documentclass[border=5pt]{standalone}
usepackage{pgfplots}
% borrowed styles from Jake's answer at
% <http://tex.stackexchange.com/a/301991/95441>
pgfplotsset{
% % filter symbolic values
% discard if not symbolic/.style 2 args={
% % suppress LOG messages about the filtered points
% filter discard warning=false,
% x filter/.append code={
% edeftempa{thisrow{#1}}
% edeftempb{#2}
% ifxtempatempb
% else
% defpgfmathresult{NaN}
% fi
% },
% },
% filter numerical values
% (not needed here, but just for completeness)
discard if not/.style 2 args={
% suppress LOG messages about the filtered points
filter discard warning=false,
x filter/.append code={
ifdimthisrow{#1} pt=#2pt
else
defpgfmathresult{NaN}
fi
},
},
}
begin{document}
begin{tikzpicture}
begin{axis}[
ybar,
symbolic x coords={
Human-Human,
Human-Tak,
Human-Gold Standard,
Tak-Gold Standard
},
enlarge x limits=0.2,
]
foreach i in {0,1,2} {
addplot+ [
discard if not={difficulty}{i},
] table [
col sep=comma,
x=type,
y=kappa,
] {combined-kappas.csv};
addlegendentryexpanded{i}
}
end{axis}
end{tikzpicture}
end{document}


image showing the result of above code






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f482776%2fgrouped-bar-chart-in-pgfplots-from-file-selecting-certain-rows%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    To answer to your comment below the question:

    I think the linked answer in my comment is what you are searching for. But there is one remaining problem that is, that you have multiple entries for one bar sometimes which results in multiple bars plotted. In your image there is some kind of error bar given to the bars.



    The error bars can also be given to bars, but of course for that you need to modify your CSV file accordingly.



    (Please note that this answer is just to prove that this in principle is what you are searching for and thus the resulting image does not look very nice.)



    % used PGFPlots v1.16
    begin{filecontents*}{combined-kappas.csv}
    r1,r2,type,kappa,difficulty
    Alex,Tak,Human-Human,0.9878019029031471,0
    Alex,Inferred,Human-Tak,0.6199032480995161,0
    Alex,Intended,Human-Gold Standard,1,0
    Tak,Inferred,Human-Tak,0.6081143384047948,0
    Tak,Intended,Human-Gold Standard,0.9878019029031471,0
    Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
    Alex,Tak,Human-Human, 0.791208791208791,1
    Alex,Inferred,Human-Tak,0.306901088386556,1
    Alex,Intended,Human-Gold Standard,0.844389844389844,1
    Tak,Inferred,Human-Tak,0.245305729417429,1
    Tak,Intended,Human-Gold Standard,0.757327238504975,1
    Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
    Alex,Tak,Human-Human,0.547137761168677,2
    Alex,Inferred,Human-Tak,0.137205030380104,2
    Alex,Intended,Human-Gold Standard,0.262046204620462,2
    Tak,Inferred,Human-Tak,0.137288621381485,2
    Tak,Intended,Human-Gold Standard,0.280682000965096,2
    Intended,Inferred,Tak-Gold Standard,0.097688926697859,2
    end{filecontents*}
    documentclass[border=5pt]{standalone}
    usepackage{pgfplots}
    % borrowed styles from Jake's answer at
    % <http://tex.stackexchange.com/a/301991/95441>
    pgfplotsset{
    % % filter symbolic values
    % discard if not symbolic/.style 2 args={
    % % suppress LOG messages about the filtered points
    % filter discard warning=false,
    % x filter/.append code={
    % edeftempa{thisrow{#1}}
    % edeftempb{#2}
    % ifxtempatempb
    % else
    % defpgfmathresult{NaN}
    % fi
    % },
    % },
    % filter numerical values
    % (not needed here, but just for completeness)
    discard if not/.style 2 args={
    % suppress LOG messages about the filtered points
    filter discard warning=false,
    x filter/.append code={
    ifdimthisrow{#1} pt=#2pt
    else
    defpgfmathresult{NaN}
    fi
    },
    },
    }
    begin{document}
    begin{tikzpicture}
    begin{axis}[
    ybar,
    symbolic x coords={
    Human-Human,
    Human-Tak,
    Human-Gold Standard,
    Tak-Gold Standard
    },
    enlarge x limits=0.2,
    ]
    foreach i in {0,1,2} {
    addplot+ [
    discard if not={difficulty}{i},
    ] table [
    col sep=comma,
    x=type,
    y=kappa,
    ] {combined-kappas.csv};
    addlegendentryexpanded{i}
    }
    end{axis}
    end{tikzpicture}
    end{document}


    image showing the result of above code






    share|improve this answer




























      0














      To answer to your comment below the question:

      I think the linked answer in my comment is what you are searching for. But there is one remaining problem that is, that you have multiple entries for one bar sometimes which results in multiple bars plotted. In your image there is some kind of error bar given to the bars.



      The error bars can also be given to bars, but of course for that you need to modify your CSV file accordingly.



      (Please note that this answer is just to prove that this in principle is what you are searching for and thus the resulting image does not look very nice.)



      % used PGFPlots v1.16
      begin{filecontents*}{combined-kappas.csv}
      r1,r2,type,kappa,difficulty
      Alex,Tak,Human-Human,0.9878019029031471,0
      Alex,Inferred,Human-Tak,0.6199032480995161,0
      Alex,Intended,Human-Gold Standard,1,0
      Tak,Inferred,Human-Tak,0.6081143384047948,0
      Tak,Intended,Human-Gold Standard,0.9878019029031471,0
      Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
      Alex,Tak,Human-Human, 0.791208791208791,1
      Alex,Inferred,Human-Tak,0.306901088386556,1
      Alex,Intended,Human-Gold Standard,0.844389844389844,1
      Tak,Inferred,Human-Tak,0.245305729417429,1
      Tak,Intended,Human-Gold Standard,0.757327238504975,1
      Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
      Alex,Tak,Human-Human,0.547137761168677,2
      Alex,Inferred,Human-Tak,0.137205030380104,2
      Alex,Intended,Human-Gold Standard,0.262046204620462,2
      Tak,Inferred,Human-Tak,0.137288621381485,2
      Tak,Intended,Human-Gold Standard,0.280682000965096,2
      Intended,Inferred,Tak-Gold Standard,0.097688926697859,2
      end{filecontents*}
      documentclass[border=5pt]{standalone}
      usepackage{pgfplots}
      % borrowed styles from Jake's answer at
      % <http://tex.stackexchange.com/a/301991/95441>
      pgfplotsset{
      % % filter symbolic values
      % discard if not symbolic/.style 2 args={
      % % suppress LOG messages about the filtered points
      % filter discard warning=false,
      % x filter/.append code={
      % edeftempa{thisrow{#1}}
      % edeftempb{#2}
      % ifxtempatempb
      % else
      % defpgfmathresult{NaN}
      % fi
      % },
      % },
      % filter numerical values
      % (not needed here, but just for completeness)
      discard if not/.style 2 args={
      % suppress LOG messages about the filtered points
      filter discard warning=false,
      x filter/.append code={
      ifdimthisrow{#1} pt=#2pt
      else
      defpgfmathresult{NaN}
      fi
      },
      },
      }
      begin{document}
      begin{tikzpicture}
      begin{axis}[
      ybar,
      symbolic x coords={
      Human-Human,
      Human-Tak,
      Human-Gold Standard,
      Tak-Gold Standard
      },
      enlarge x limits=0.2,
      ]
      foreach i in {0,1,2} {
      addplot+ [
      discard if not={difficulty}{i},
      ] table [
      col sep=comma,
      x=type,
      y=kappa,
      ] {combined-kappas.csv};
      addlegendentryexpanded{i}
      }
      end{axis}
      end{tikzpicture}
      end{document}


      image showing the result of above code






      share|improve this answer


























        0












        0








        0







        To answer to your comment below the question:

        I think the linked answer in my comment is what you are searching for. But there is one remaining problem that is, that you have multiple entries for one bar sometimes which results in multiple bars plotted. In your image there is some kind of error bar given to the bars.



        The error bars can also be given to bars, but of course for that you need to modify your CSV file accordingly.



        (Please note that this answer is just to prove that this in principle is what you are searching for and thus the resulting image does not look very nice.)



        % used PGFPlots v1.16
        begin{filecontents*}{combined-kappas.csv}
        r1,r2,type,kappa,difficulty
        Alex,Tak,Human-Human,0.9878019029031471,0
        Alex,Inferred,Human-Tak,0.6199032480995161,0
        Alex,Intended,Human-Gold Standard,1,0
        Tak,Inferred,Human-Tak,0.6081143384047948,0
        Tak,Intended,Human-Gold Standard,0.9878019029031471,0
        Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
        Alex,Tak,Human-Human, 0.791208791208791,1
        Alex,Inferred,Human-Tak,0.306901088386556,1
        Alex,Intended,Human-Gold Standard,0.844389844389844,1
        Tak,Inferred,Human-Tak,0.245305729417429,1
        Tak,Intended,Human-Gold Standard,0.757327238504975,1
        Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
        Alex,Tak,Human-Human,0.547137761168677,2
        Alex,Inferred,Human-Tak,0.137205030380104,2
        Alex,Intended,Human-Gold Standard,0.262046204620462,2
        Tak,Inferred,Human-Tak,0.137288621381485,2
        Tak,Intended,Human-Gold Standard,0.280682000965096,2
        Intended,Inferred,Tak-Gold Standard,0.097688926697859,2
        end{filecontents*}
        documentclass[border=5pt]{standalone}
        usepackage{pgfplots}
        % borrowed styles from Jake's answer at
        % <http://tex.stackexchange.com/a/301991/95441>
        pgfplotsset{
        % % filter symbolic values
        % discard if not symbolic/.style 2 args={
        % % suppress LOG messages about the filtered points
        % filter discard warning=false,
        % x filter/.append code={
        % edeftempa{thisrow{#1}}
        % edeftempb{#2}
        % ifxtempatempb
        % else
        % defpgfmathresult{NaN}
        % fi
        % },
        % },
        % filter numerical values
        % (not needed here, but just for completeness)
        discard if not/.style 2 args={
        % suppress LOG messages about the filtered points
        filter discard warning=false,
        x filter/.append code={
        ifdimthisrow{#1} pt=#2pt
        else
        defpgfmathresult{NaN}
        fi
        },
        },
        }
        begin{document}
        begin{tikzpicture}
        begin{axis}[
        ybar,
        symbolic x coords={
        Human-Human,
        Human-Tak,
        Human-Gold Standard,
        Tak-Gold Standard
        },
        enlarge x limits=0.2,
        ]
        foreach i in {0,1,2} {
        addplot+ [
        discard if not={difficulty}{i},
        ] table [
        col sep=comma,
        x=type,
        y=kappa,
        ] {combined-kappas.csv};
        addlegendentryexpanded{i}
        }
        end{axis}
        end{tikzpicture}
        end{document}


        image showing the result of above code






        share|improve this answer













        To answer to your comment below the question:

        I think the linked answer in my comment is what you are searching for. But there is one remaining problem that is, that you have multiple entries for one bar sometimes which results in multiple bars plotted. In your image there is some kind of error bar given to the bars.



        The error bars can also be given to bars, but of course for that you need to modify your CSV file accordingly.



        (Please note that this answer is just to prove that this in principle is what you are searching for and thus the resulting image does not look very nice.)



        % used PGFPlots v1.16
        begin{filecontents*}{combined-kappas.csv}
        r1,r2,type,kappa,difficulty
        Alex,Tak,Human-Human,0.9878019029031471,0
        Alex,Inferred,Human-Tak,0.6199032480995161,0
        Alex,Intended,Human-Gold Standard,1,0
        Tak,Inferred,Human-Tak,0.6081143384047948,0
        Tak,Intended,Human-Gold Standard,0.9878019029031471,0
        Intended,Inferred,Tak-Gold Standard,0.6199032480995161,0
        Alex,Tak,Human-Human, 0.791208791208791,1
        Alex,Inferred,Human-Tak,0.306901088386556,1
        Alex,Intended,Human-Gold Standard,0.844389844389844,1
        Tak,Inferred,Human-Tak,0.245305729417429,1
        Tak,Intended,Human-Gold Standard,0.757327238504975,1
        Intended,Inferred,Tak-Gold Standard,0.337421837421837,1
        Alex,Tak,Human-Human,0.547137761168677,2
        Alex,Inferred,Human-Tak,0.137205030380104,2
        Alex,Intended,Human-Gold Standard,0.262046204620462,2
        Tak,Inferred,Human-Tak,0.137288621381485,2
        Tak,Intended,Human-Gold Standard,0.280682000965096,2
        Intended,Inferred,Tak-Gold Standard,0.097688926697859,2
        end{filecontents*}
        documentclass[border=5pt]{standalone}
        usepackage{pgfplots}
        % borrowed styles from Jake's answer at
        % <http://tex.stackexchange.com/a/301991/95441>
        pgfplotsset{
        % % filter symbolic values
        % discard if not symbolic/.style 2 args={
        % % suppress LOG messages about the filtered points
        % filter discard warning=false,
        % x filter/.append code={
        % edeftempa{thisrow{#1}}
        % edeftempb{#2}
        % ifxtempatempb
        % else
        % defpgfmathresult{NaN}
        % fi
        % },
        % },
        % filter numerical values
        % (not needed here, but just for completeness)
        discard if not/.style 2 args={
        % suppress LOG messages about the filtered points
        filter discard warning=false,
        x filter/.append code={
        ifdimthisrow{#1} pt=#2pt
        else
        defpgfmathresult{NaN}
        fi
        },
        },
        }
        begin{document}
        begin{tikzpicture}
        begin{axis}[
        ybar,
        symbolic x coords={
        Human-Human,
        Human-Tak,
        Human-Gold Standard,
        Tak-Gold Standard
        },
        enlarge x limits=0.2,
        ]
        foreach i in {0,1,2} {
        addplot+ [
        discard if not={difficulty}{i},
        ] table [
        col sep=comma,
        x=type,
        y=kappa,
        ] {combined-kappas.csv};
        addlegendentryexpanded{i}
        }
        end{axis}
        end{tikzpicture}
        end{document}


        image showing the result of above code







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        Stefan PinnowStefan Pinnow

        20.3k83578




        20.3k83578






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f482776%2fgrouped-bar-chart-in-pgfplots-from-file-selecting-certain-rows%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)