Plotting each value for x-axis when plotting from file with TikZ
Clash Royale CLAN TAG#URR8PPP
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:
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
add a comment |
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:
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
3
Related: tex.stackexchange.com/a/241701/31034
– ferahfeza
Jan 31 at 9:36
add a comment |
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:
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
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:
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
tikz-pgf plot
asked Jan 31 at 8:42
matkaplukumatkapluku
95115
95115
3
Related: tex.stackexchange.com/a/241701/31034
– ferahfeza
Jan 31 at 9:36
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
]
Wouldn't a bar plot be more appropriate for this data?
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
add a comment |
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:
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
]
Wouldn't a bar plot be more appropriate for this data?
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
add a comment |
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
]
Wouldn't a bar plot be more appropriate for this data?
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
add a comment |
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
]
Wouldn't a bar plot be more appropriate for this data?
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
]
Wouldn't a bar plot be more appropriate for this data?
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
add a comment |
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
add a comment |
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:
add a comment |
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:
add a comment |
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:
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:
answered Jan 31 at 10:12
RaajaRaaja
4,13121038
4,13121038
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
3
Related: tex.stackexchange.com/a/241701/31034
– ferahfeza
Jan 31 at 9:36