How to use bar chart to represent percentage in table?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite
2












I want to use black and gray bar to represent some percentages. Gray is the basic color on bottom,the black is the real percentage.
enter image description here







share|improve this question






















  • Welcome to TeX.SX! Intresting question. What have you done so far? Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem.
    – Bobyandbob
    Aug 9 at 8:45















up vote
5
down vote

favorite
2












I want to use black and gray bar to represent some percentages. Gray is the basic color on bottom,the black is the real percentage.
enter image description here







share|improve this question






















  • Welcome to TeX.SX! Intresting question. What have you done so far? Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem.
    – Bobyandbob
    Aug 9 at 8:45













up vote
5
down vote

favorite
2









up vote
5
down vote

favorite
2






2





I want to use black and gray bar to represent some percentages. Gray is the basic color on bottom,the black is the real percentage.
enter image description here







share|improve this question














I want to use black and gray bar to represent some percentages. Gray is the basic color on bottom,the black is the real percentage.
enter image description here









share|improve this question













share|improve this question




share|improve this question








edited Aug 9 at 9:45









Bernard

155k762189




155k762189










asked Aug 9 at 8:33









liang tan

224




224











  • Welcome to TeX.SX! Intresting question. What have you done so far? Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem.
    – Bobyandbob
    Aug 9 at 8:45

















  • Welcome to TeX.SX! Intresting question. What have you done so far? Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem.
    – Bobyandbob
    Aug 9 at 8:45
















Welcome to TeX.SX! Intresting question. What have you done so far? Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem.
– Bobyandbob
Aug 9 at 8:45





Welcome to TeX.SX! Intresting question. What have you done so far? Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem.
– Bobyandbob
Aug 9 at 8:45











3 Answers
3






active

oldest

votes

















up vote
6
down vote



accepted










MAX defines the maximal width of the bar, which is 1



documentclassarticle
usepackagexcolor
newlengthMAX setlengthMAX5mm
newcommand*Chart[1]#1~rlaptextcolorblack!20ruleMAX2exrule#1MAX2ex
begindocument

begintabular@ l l l @
Pull Up Method & Chart1.000 & Chart0.600\
Move Field & Chart0.269 & Chart0.783
endtabular

enddocument


enter image description here



It is also possible to change the height of the bar to the height of the characters.






share|improve this answer





























    up vote
    3
    down vote













    Alternativly you could create a single bar like this: Is it possible to create a barchart in a table?.
    With usepackagecalc you could compute the differnce between the max value (defined with newlengthWIDTHOFBAR and setlengthWIDTHOFBAR1cm) to get the percentages representation with the following definiton.



    Bar chart definition:



    defblackwhitebar#1%%
    #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt


    Solution:



    enter image description here



    MWE:



    documentclassarticle
    usepackagebooktabs
    usepackagexcolor
    usepackagecalc

    newlengthWIDTHOFBAR
    setlengthWIDTHOFBAR1cm

    defblackwhitebar#1%%
    #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt

    begindocument
    begintable
    centering
    begintabular l r r r r r
    toprule
    & multicolumn2cA & multicolumn2cB\
    cmidrule(lr)2-3 cmidrule(l)4-5
    Type & Precision & Recall & Precision & Recall \midrule
    Move Type & blackwhitebar1.000 &blackwhitebar0.968 & ... & ... \
    Extract Type & blackwhitebar1.000 &blackwhitebar0.600 & ... & . \
    bottomrule
    endtabular
    endtable

    enddocument





    share|improve this answer
















    • 1




      Thank you for your answer. I have finished the table , it's very cool
      – liang tan
      Aug 13 at 7:34


















    up vote
    2
    down vote













    Here is a solution using tikz:



    documentclassarticle 


    usepackagetikz

    newcommandDrawPercentageBar[1]%
    begintikzpicture
    fill[color=black] (0.0 , 0.0) rectangle (#1*3ex , 1.5ex );
    fill[color=gray] (#1*3ex , 0.0) rectangle (3.0ex, 1.5ex);
    endtikzpicture%


    begindocument

    0.800 DrawPercentageBar0.8


    enddocument


    Here is the result:enter image description here



    You could also change the dimension of the bar depending on your needs.






    share|improve this answer


















    • 1




      You shoulkd use newcommandDrawPercentageBar[1]{% and also endtikzpicture%. Then you do not get additional spaces in the output.
      – Herbert
      Aug 9 at 9:26










    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f445275%2fhow-to-use-bar-chart-to-represent-percentage-in-table%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    MAX defines the maximal width of the bar, which is 1



    documentclassarticle
    usepackagexcolor
    newlengthMAX setlengthMAX5mm
    newcommand*Chart[1]#1~rlaptextcolorblack!20ruleMAX2exrule#1MAX2ex
    begindocument

    begintabular@ l l l @
    Pull Up Method & Chart1.000 & Chart0.600\
    Move Field & Chart0.269 & Chart0.783
    endtabular

    enddocument


    enter image description here



    It is also possible to change the height of the bar to the height of the characters.






    share|improve this answer


























      up vote
      6
      down vote



      accepted










      MAX defines the maximal width of the bar, which is 1



      documentclassarticle
      usepackagexcolor
      newlengthMAX setlengthMAX5mm
      newcommand*Chart[1]#1~rlaptextcolorblack!20ruleMAX2exrule#1MAX2ex
      begindocument

      begintabular@ l l l @
      Pull Up Method & Chart1.000 & Chart0.600\
      Move Field & Chart0.269 & Chart0.783
      endtabular

      enddocument


      enter image description here



      It is also possible to change the height of the bar to the height of the characters.






      share|improve this answer
























        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        MAX defines the maximal width of the bar, which is 1



        documentclassarticle
        usepackagexcolor
        newlengthMAX setlengthMAX5mm
        newcommand*Chart[1]#1~rlaptextcolorblack!20ruleMAX2exrule#1MAX2ex
        begindocument

        begintabular@ l l l @
        Pull Up Method & Chart1.000 & Chart0.600\
        Move Field & Chart0.269 & Chart0.783
        endtabular

        enddocument


        enter image description here



        It is also possible to change the height of the bar to the height of the characters.






        share|improve this answer














        MAX defines the maximal width of the bar, which is 1



        documentclassarticle
        usepackagexcolor
        newlengthMAX setlengthMAX5mm
        newcommand*Chart[1]#1~rlaptextcolorblack!20ruleMAX2exrule#1MAX2ex
        begindocument

        begintabular@ l l l @
        Pull Up Method & Chart1.000 & Chart0.600\
        Move Field & Chart0.269 & Chart0.783
        endtabular

        enddocument


        enter image description here



        It is also possible to change the height of the bar to the height of the characters.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 9 at 9:48

























        answered Aug 9 at 8:49









        Herbert

        261k21395703




        261k21395703




















            up vote
            3
            down vote













            Alternativly you could create a single bar like this: Is it possible to create a barchart in a table?.
            With usepackagecalc you could compute the differnce between the max value (defined with newlengthWIDTHOFBAR and setlengthWIDTHOFBAR1cm) to get the percentages representation with the following definiton.



            Bar chart definition:



            defblackwhitebar#1%%
            #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt


            Solution:



            enter image description here



            MWE:



            documentclassarticle
            usepackagebooktabs
            usepackagexcolor
            usepackagecalc

            newlengthWIDTHOFBAR
            setlengthWIDTHOFBAR1cm

            defblackwhitebar#1%%
            #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt

            begindocument
            begintable
            centering
            begintabular l r r r r r
            toprule
            & multicolumn2cA & multicolumn2cB\
            cmidrule(lr)2-3 cmidrule(l)4-5
            Type & Precision & Recall & Precision & Recall \midrule
            Move Type & blackwhitebar1.000 &blackwhitebar0.968 & ... & ... \
            Extract Type & blackwhitebar1.000 &blackwhitebar0.600 & ... & . \
            bottomrule
            endtabular
            endtable

            enddocument





            share|improve this answer
















            • 1




              Thank you for your answer. I have finished the table , it's very cool
              – liang tan
              Aug 13 at 7:34















            up vote
            3
            down vote













            Alternativly you could create a single bar like this: Is it possible to create a barchart in a table?.
            With usepackagecalc you could compute the differnce between the max value (defined with newlengthWIDTHOFBAR and setlengthWIDTHOFBAR1cm) to get the percentages representation with the following definiton.



            Bar chart definition:



            defblackwhitebar#1%%
            #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt


            Solution:



            enter image description here



            MWE:



            documentclassarticle
            usepackagebooktabs
            usepackagexcolor
            usepackagecalc

            newlengthWIDTHOFBAR
            setlengthWIDTHOFBAR1cm

            defblackwhitebar#1%%
            #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt

            begindocument
            begintable
            centering
            begintabular l r r r r r
            toprule
            & multicolumn2cA & multicolumn2cB\
            cmidrule(lr)2-3 cmidrule(l)4-5
            Type & Precision & Recall & Precision & Recall \midrule
            Move Type & blackwhitebar1.000 &blackwhitebar0.968 & ... & ... \
            Extract Type & blackwhitebar1.000 &blackwhitebar0.600 & ... & . \
            bottomrule
            endtabular
            endtable

            enddocument





            share|improve this answer
















            • 1




              Thank you for your answer. I have finished the table , it's very cool
              – liang tan
              Aug 13 at 7:34













            up vote
            3
            down vote










            up vote
            3
            down vote









            Alternativly you could create a single bar like this: Is it possible to create a barchart in a table?.
            With usepackagecalc you could compute the differnce between the max value (defined with newlengthWIDTHOFBAR and setlengthWIDTHOFBAR1cm) to get the percentages representation with the following definiton.



            Bar chart definition:



            defblackwhitebar#1%%
            #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt


            Solution:



            enter image description here



            MWE:



            documentclassarticle
            usepackagebooktabs
            usepackagexcolor
            usepackagecalc

            newlengthWIDTHOFBAR
            setlengthWIDTHOFBAR1cm

            defblackwhitebar#1%%
            #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt

            begindocument
            begintable
            centering
            begintabular l r r r r r
            toprule
            & multicolumn2cA & multicolumn2cB\
            cmidrule(lr)2-3 cmidrule(l)4-5
            Type & Precision & Recall & Precision & Recall \midrule
            Move Type & blackwhitebar1.000 &blackwhitebar0.968 & ... & ... \
            Extract Type & blackwhitebar1.000 &blackwhitebar0.600 & ... & . \
            bottomrule
            endtabular
            endtable

            enddocument





            share|improve this answer












            Alternativly you could create a single bar like this: Is it possible to create a barchart in a table?.
            With usepackagecalc you could compute the differnce between the max value (defined with newlengthWIDTHOFBAR and setlengthWIDTHOFBAR1cm) to get the percentages representation with the following definiton.



            Bar chart definition:



            defblackwhitebar#1%%
            #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt


            Solution:



            enter image description here



            MWE:



            documentclassarticle
            usepackagebooktabs
            usepackagexcolor
            usepackagecalc

            newlengthWIDTHOFBAR
            setlengthWIDTHOFBAR1cm

            defblackwhitebar#1%%
            #1 colorblack!100rule#1cm8ptcolorblack!30ruleWIDTHOFBAR - #1 cm8pt

            begindocument
            begintable
            centering
            begintabular l r r r r r
            toprule
            & multicolumn2cA & multicolumn2cB\
            cmidrule(lr)2-3 cmidrule(l)4-5
            Type & Precision & Recall & Precision & Recall \midrule
            Move Type & blackwhitebar1.000 &blackwhitebar0.968 & ... & ... \
            Extract Type & blackwhitebar1.000 &blackwhitebar0.600 & ... & . \
            bottomrule
            endtabular
            endtable

            enddocument






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 9 at 9:39









            Bobyandbob

            3,80851158




            3,80851158







            • 1




              Thank you for your answer. I have finished the table , it's very cool
              – liang tan
              Aug 13 at 7:34













            • 1




              Thank you for your answer. I have finished the table , it's very cool
              – liang tan
              Aug 13 at 7:34








            1




            1




            Thank you for your answer. I have finished the table , it's very cool
            – liang tan
            Aug 13 at 7:34





            Thank you for your answer. I have finished the table , it's very cool
            – liang tan
            Aug 13 at 7:34











            up vote
            2
            down vote













            Here is a solution using tikz:



            documentclassarticle 


            usepackagetikz

            newcommandDrawPercentageBar[1]%
            begintikzpicture
            fill[color=black] (0.0 , 0.0) rectangle (#1*3ex , 1.5ex );
            fill[color=gray] (#1*3ex , 0.0) rectangle (3.0ex, 1.5ex);
            endtikzpicture%


            begindocument

            0.800 DrawPercentageBar0.8


            enddocument


            Here is the result:enter image description here



            You could also change the dimension of the bar depending on your needs.






            share|improve this answer


















            • 1




              You shoulkd use newcommandDrawPercentageBar[1]{% and also endtikzpicture%. Then you do not get additional spaces in the output.
              – Herbert
              Aug 9 at 9:26














            up vote
            2
            down vote













            Here is a solution using tikz:



            documentclassarticle 


            usepackagetikz

            newcommandDrawPercentageBar[1]%
            begintikzpicture
            fill[color=black] (0.0 , 0.0) rectangle (#1*3ex , 1.5ex );
            fill[color=gray] (#1*3ex , 0.0) rectangle (3.0ex, 1.5ex);
            endtikzpicture%


            begindocument

            0.800 DrawPercentageBar0.8


            enddocument


            Here is the result:enter image description here



            You could also change the dimension of the bar depending on your needs.






            share|improve this answer


















            • 1




              You shoulkd use newcommandDrawPercentageBar[1]{% and also endtikzpicture%. Then you do not get additional spaces in the output.
              – Herbert
              Aug 9 at 9:26












            up vote
            2
            down vote










            up vote
            2
            down vote









            Here is a solution using tikz:



            documentclassarticle 


            usepackagetikz

            newcommandDrawPercentageBar[1]%
            begintikzpicture
            fill[color=black] (0.0 , 0.0) rectangle (#1*3ex , 1.5ex );
            fill[color=gray] (#1*3ex , 0.0) rectangle (3.0ex, 1.5ex);
            endtikzpicture%


            begindocument

            0.800 DrawPercentageBar0.8


            enddocument


            Here is the result:enter image description here



            You could also change the dimension of the bar depending on your needs.






            share|improve this answer














            Here is a solution using tikz:



            documentclassarticle 


            usepackagetikz

            newcommandDrawPercentageBar[1]%
            begintikzpicture
            fill[color=black] (0.0 , 0.0) rectangle (#1*3ex , 1.5ex );
            fill[color=gray] (#1*3ex , 0.0) rectangle (3.0ex, 1.5ex);
            endtikzpicture%


            begindocument

            0.800 DrawPercentageBar0.8


            enddocument


            Here is the result:enter image description here



            You could also change the dimension of the bar depending on your needs.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 9 at 9:53

























            answered Aug 9 at 8:56









            Source

            52018




            52018







            • 1




              You shoulkd use newcommandDrawPercentageBar[1]{% and also endtikzpicture%. Then you do not get additional spaces in the output.
              – Herbert
              Aug 9 at 9:26












            • 1




              You shoulkd use newcommandDrawPercentageBar[1]{% and also endtikzpicture%. Then you do not get additional spaces in the output.
              – Herbert
              Aug 9 at 9:26







            1




            1




            You shoulkd use newcommandDrawPercentageBar[1]{% and also endtikzpicture%. Then you do not get additional spaces in the output.
            – Herbert
            Aug 9 at 9:26




            You shoulkd use newcommandDrawPercentageBar[1]{% and also endtikzpicture%. Then you do not get additional spaces in the output.
            – Herbert
            Aug 9 at 9:26

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f445275%2fhow-to-use-bar-chart-to-represent-percentage-in-table%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery