Plotting each value for x-axis when plotting from file with TikZ

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












2















I want to plot data from file using TikZ, and I successfully do. However, I want to plot every value for the x-axis along the x-axis and remove the comma that appears for each number.



My current output:



enter image description here



Using the following code:



documentclassarticle
usepackagepgfplotstable
usepackagepgfplots
usepackagefilecontents


beginfilecontents*kvinner.data
anno,andel
1998,8.70
1999,22.73
2000,10.71
2001,26.32
2002,16.33
2003,23.53
2004,20.69
2005,22.08
2006,21.51
2007,26.67
2008,24.10
2009,22.33
2010,19.64
2011,21.05
2012,21.19
2013,20.44
2014,19.69
2015,21.58
2016,25.00
2017,27.38
2018,30.14
endfilecontents*


begindocument

begintikzpicture

beginaxis
addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
endaxis

endtikzpicture

enddocument


The x-axis contains years, and the y-axis a precentage. How may I plot year value without the comma, and plot every year value along the x-axis?










share|improve this question

















  • 3





    Related: tex.stackexchange.com/a/241701/31034

    – ferahfeza
    Jan 31 at 9:36















2















I want to plot data from file using TikZ, and I successfully do. However, I want to plot every value for the x-axis along the x-axis and remove the comma that appears for each number.



My current output:



enter image description here



Using the following code:



documentclassarticle
usepackagepgfplotstable
usepackagepgfplots
usepackagefilecontents


beginfilecontents*kvinner.data
anno,andel
1998,8.70
1999,22.73
2000,10.71
2001,26.32
2002,16.33
2003,23.53
2004,20.69
2005,22.08
2006,21.51
2007,26.67
2008,24.10
2009,22.33
2010,19.64
2011,21.05
2012,21.19
2013,20.44
2014,19.69
2015,21.58
2016,25.00
2017,27.38
2018,30.14
endfilecontents*


begindocument

begintikzpicture

beginaxis
addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
endaxis

endtikzpicture

enddocument


The x-axis contains years, and the y-axis a precentage. How may I plot year value without the comma, and plot every year value along the x-axis?










share|improve this question

















  • 3





    Related: tex.stackexchange.com/a/241701/31034

    – ferahfeza
    Jan 31 at 9:36













2












2








2








I want to plot data from file using TikZ, and I successfully do. However, I want to plot every value for the x-axis along the x-axis and remove the comma that appears for each number.



My current output:



enter image description here



Using the following code:



documentclassarticle
usepackagepgfplotstable
usepackagepgfplots
usepackagefilecontents


beginfilecontents*kvinner.data
anno,andel
1998,8.70
1999,22.73
2000,10.71
2001,26.32
2002,16.33
2003,23.53
2004,20.69
2005,22.08
2006,21.51
2007,26.67
2008,24.10
2009,22.33
2010,19.64
2011,21.05
2012,21.19
2013,20.44
2014,19.69
2015,21.58
2016,25.00
2017,27.38
2018,30.14
endfilecontents*


begindocument

begintikzpicture

beginaxis
addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
endaxis

endtikzpicture

enddocument


The x-axis contains years, and the y-axis a precentage. How may I plot year value without the comma, and plot every year value along the x-axis?










share|improve this question














I want to plot data from file using TikZ, and I successfully do. However, I want to plot every value for the x-axis along the x-axis and remove the comma that appears for each number.



My current output:



enter image description here



Using the following code:



documentclassarticle
usepackagepgfplotstable
usepackagepgfplots
usepackagefilecontents


beginfilecontents*kvinner.data
anno,andel
1998,8.70
1999,22.73
2000,10.71
2001,26.32
2002,16.33
2003,23.53
2004,20.69
2005,22.08
2006,21.51
2007,26.67
2008,24.10
2009,22.33
2010,19.64
2011,21.05
2012,21.19
2013,20.44
2014,19.69
2015,21.58
2016,25.00
2017,27.38
2018,30.14
endfilecontents*


begindocument

begintikzpicture

beginaxis
addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
endaxis

endtikzpicture

enddocument


The x-axis contains years, and the y-axis a precentage. How may I plot year value without the comma, and plot every year value along the x-axis?







tikz-pgf plot






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 31 at 8:42









matkaplukumatkapluku

95115




95115







  • 3





    Related: tex.stackexchange.com/a/241701/31034

    – ferahfeza
    Jan 31 at 9:36












  • 3





    Related: tex.stackexchange.com/a/241701/31034

    – ferahfeza
    Jan 31 at 9:36







3




3





Related: tex.stackexchange.com/a/241701/31034

– ferahfeza
Jan 31 at 9:36





Related: tex.stackexchange.com/a/241701/31034

– ferahfeza
Jan 31 at 9:36










2 Answers
2






active

oldest

votes


















4














A bit cramped, but using the following preamble you can do it:



beginaxis[
xtick = 1998, 1999, ..., 2018,
x tick label style=
font=small,
rotate=90,
/pgf/number format/.cd,%
scaled x ticks = false,
set thousands separator=,
fixed
]


enter image description here



Wouldn't a bar plot be more appropriate for this data?






share|improve this answer

























  • Thank you! Yes, you're right, it would be more appropriate with a bar plot. I'll see what I end up with. Anyhow, this is good knowledge. :)

    – matkapluku
    Jan 31 at 10:27


















4














You can directly edit the number format of pgfplot options as in



beginaxis[x tick label style=/pgf/number format/.cd,%
scaled x ticks = false,
set thousands separator=,
fixed]
...
endaxis


MWE:



documentclassstandalone
usepackagepgfplotstable
usepackagepgfplots
usepackagefilecontents


beginfilecontents*kvinner.data
anno,andel
1998,8.70
1999,22.73
2000,10.71
2001,26.32
2002,16.33
2003,23.53
2004,20.69
2005,22.08
2006,21.51
2007,26.67
2008,24.10
2009,22.33
2010,19.64
2011,21.05
2012,21.19
2013,20.44
2014,19.69
2015,21.58
2016,25.00
2017,27.38
2018,30.14
endfilecontents*


begindocument

begintikzpicture

beginaxis[x tick label style=/pgf/number format/.cd,%
scaled x ticks = false,
set thousands separator=,
fixed]
addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
endaxis

endtikzpicture

enddocument


to get:



enter image description here






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%2f472688%2fplotting-each-value-for-x-axis-when-plotting-from-file-with-tikz%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    A bit cramped, but using the following preamble you can do it:



    beginaxis[
    xtick = 1998, 1999, ..., 2018,
    x tick label style=
    font=small,
    rotate=90,
    /pgf/number format/.cd,%
    scaled x ticks = false,
    set thousands separator=,
    fixed
    ]


    enter image description here



    Wouldn't a bar plot be more appropriate for this data?






    share|improve this answer

























    • Thank you! Yes, you're right, it would be more appropriate with a bar plot. I'll see what I end up with. Anyhow, this is good knowledge. :)

      – matkapluku
      Jan 31 at 10:27















    4














    A bit cramped, but using the following preamble you can do it:



    beginaxis[
    xtick = 1998, 1999, ..., 2018,
    x tick label style=
    font=small,
    rotate=90,
    /pgf/number format/.cd,%
    scaled x ticks = false,
    set thousands separator=,
    fixed
    ]


    enter image description here



    Wouldn't a bar plot be more appropriate for this data?






    share|improve this answer

























    • Thank you! Yes, you're right, it would be more appropriate with a bar plot. I'll see what I end up with. Anyhow, this is good knowledge. :)

      – matkapluku
      Jan 31 at 10:27













    4












    4








    4







    A bit cramped, but using the following preamble you can do it:



    beginaxis[
    xtick = 1998, 1999, ..., 2018,
    x tick label style=
    font=small,
    rotate=90,
    /pgf/number format/.cd,%
    scaled x ticks = false,
    set thousands separator=,
    fixed
    ]


    enter image description here



    Wouldn't a bar plot be more appropriate for this data?






    share|improve this answer















    A bit cramped, but using the following preamble you can do it:



    beginaxis[
    xtick = 1998, 1999, ..., 2018,
    x tick label style=
    font=small,
    rotate=90,
    /pgf/number format/.cd,%
    scaled x ticks = false,
    set thousands separator=,
    fixed
    ]


    enter image description here



    Wouldn't a bar plot be more appropriate for this data?







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 31 at 13:18

























    answered Jan 31 at 10:22









    RmanoRmano

    8,06121647




    8,06121647












    • Thank you! Yes, you're right, it would be more appropriate with a bar plot. I'll see what I end up with. Anyhow, this is good knowledge. :)

      – matkapluku
      Jan 31 at 10:27

















    • Thank you! Yes, you're right, it would be more appropriate with a bar plot. I'll see what I end up with. Anyhow, this is good knowledge. :)

      – matkapluku
      Jan 31 at 10:27
















    Thank you! Yes, you're right, it would be more appropriate with a bar plot. I'll see what I end up with. Anyhow, this is good knowledge. :)

    – matkapluku
    Jan 31 at 10:27





    Thank you! Yes, you're right, it would be more appropriate with a bar plot. I'll see what I end up with. Anyhow, this is good knowledge. :)

    – matkapluku
    Jan 31 at 10:27











    4














    You can directly edit the number format of pgfplot options as in



    beginaxis[x tick label style=/pgf/number format/.cd,%
    scaled x ticks = false,
    set thousands separator=,
    fixed]
    ...
    endaxis


    MWE:



    documentclassstandalone
    usepackagepgfplotstable
    usepackagepgfplots
    usepackagefilecontents


    beginfilecontents*kvinner.data
    anno,andel
    1998,8.70
    1999,22.73
    2000,10.71
    2001,26.32
    2002,16.33
    2003,23.53
    2004,20.69
    2005,22.08
    2006,21.51
    2007,26.67
    2008,24.10
    2009,22.33
    2010,19.64
    2011,21.05
    2012,21.19
    2013,20.44
    2014,19.69
    2015,21.58
    2016,25.00
    2017,27.38
    2018,30.14
    endfilecontents*


    begindocument

    begintikzpicture

    beginaxis[x tick label style=/pgf/number format/.cd,%
    scaled x ticks = false,
    set thousands separator=,
    fixed]
    addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
    endaxis

    endtikzpicture

    enddocument


    to get:



    enter image description here






    share|improve this answer



























      4














      You can directly edit the number format of pgfplot options as in



      beginaxis[x tick label style=/pgf/number format/.cd,%
      scaled x ticks = false,
      set thousands separator=,
      fixed]
      ...
      endaxis


      MWE:



      documentclassstandalone
      usepackagepgfplotstable
      usepackagepgfplots
      usepackagefilecontents


      beginfilecontents*kvinner.data
      anno,andel
      1998,8.70
      1999,22.73
      2000,10.71
      2001,26.32
      2002,16.33
      2003,23.53
      2004,20.69
      2005,22.08
      2006,21.51
      2007,26.67
      2008,24.10
      2009,22.33
      2010,19.64
      2011,21.05
      2012,21.19
      2013,20.44
      2014,19.69
      2015,21.58
      2016,25.00
      2017,27.38
      2018,30.14
      endfilecontents*


      begindocument

      begintikzpicture

      beginaxis[x tick label style=/pgf/number format/.cd,%
      scaled x ticks = false,
      set thousands separator=,
      fixed]
      addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
      endaxis

      endtikzpicture

      enddocument


      to get:



      enter image description here






      share|improve this answer

























        4












        4








        4







        You can directly edit the number format of pgfplot options as in



        beginaxis[x tick label style=/pgf/number format/.cd,%
        scaled x ticks = false,
        set thousands separator=,
        fixed]
        ...
        endaxis


        MWE:



        documentclassstandalone
        usepackagepgfplotstable
        usepackagepgfplots
        usepackagefilecontents


        beginfilecontents*kvinner.data
        anno,andel
        1998,8.70
        1999,22.73
        2000,10.71
        2001,26.32
        2002,16.33
        2003,23.53
        2004,20.69
        2005,22.08
        2006,21.51
        2007,26.67
        2008,24.10
        2009,22.33
        2010,19.64
        2011,21.05
        2012,21.19
        2013,20.44
        2014,19.69
        2015,21.58
        2016,25.00
        2017,27.38
        2018,30.14
        endfilecontents*


        begindocument

        begintikzpicture

        beginaxis[x tick label style=/pgf/number format/.cd,%
        scaled x ticks = false,
        set thousands separator=,
        fixed]
        addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
        endaxis

        endtikzpicture

        enddocument


        to get:



        enter image description here






        share|improve this answer













        You can directly edit the number format of pgfplot options as in



        beginaxis[x tick label style=/pgf/number format/.cd,%
        scaled x ticks = false,
        set thousands separator=,
        fixed]
        ...
        endaxis


        MWE:



        documentclassstandalone
        usepackagepgfplotstable
        usepackagepgfplots
        usepackagefilecontents


        beginfilecontents*kvinner.data
        anno,andel
        1998,8.70
        1999,22.73
        2000,10.71
        2001,26.32
        2002,16.33
        2003,23.53
        2004,20.69
        2005,22.08
        2006,21.51
        2007,26.67
        2008,24.10
        2009,22.33
        2010,19.64
        2011,21.05
        2012,21.19
        2013,20.44
        2014,19.69
        2015,21.58
        2016,25.00
        2017,27.38
        2018,30.14
        endfilecontents*


        begindocument

        begintikzpicture

        beginaxis[x tick label style=/pgf/number format/.cd,%
        scaled x ticks = false,
        set thousands separator=,
        fixed]
        addplot table [x=anno, y=andel, col sep=comma] kvinner.data;
        endaxis

        endtikzpicture

        enddocument


        to get:



        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 31 at 10:12









        RaajaRaaja

        4,13121038




        4,13121038



























            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%2f472688%2fplotting-each-value-for-x-axis-when-plotting-from-file-with-tikz%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

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?