Issue with Graphing Points
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
So I have been trying to graph a function for my economics class. My problem is that the "axis" that are created do not match up with actual points; for example, the point (0,5) will not be on the y-axis, it is shifted over.
Here is the code for my graph:
documentclassarticle
usepackagepgfplots
begindocument
beginfigure[ht]
centering
begintikzpicture[scale=1.5,line width=1pt]
beginaxis[
color= black,
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
axis equal,
axis x line=left,
axis y line=left,
disabledatascaling,
xticklabels=,
yticklabels=,
font=scriptsize,
ticks=none,
extra x ticks=0,
extra y ticks=0,
]
draw (0,5) -- (10,0);
endaxis
endtikzpicture
endfigure
enddocument
My issue is not with creating a graph; I only put a simple line to demonstrate that the points are not lining up.
Does anyone know why this is happening? I cannot figure it out at all. Help would be much appreciated!
tikz-pgf pgfplots formatting axis
add a comment |Â
up vote
3
down vote
favorite
So I have been trying to graph a function for my economics class. My problem is that the "axis" that are created do not match up with actual points; for example, the point (0,5) will not be on the y-axis, it is shifted over.
Here is the code for my graph:
documentclassarticle
usepackagepgfplots
begindocument
beginfigure[ht]
centering
begintikzpicture[scale=1.5,line width=1pt]
beginaxis[
color= black,
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
axis equal,
axis x line=left,
axis y line=left,
disabledatascaling,
xticklabels=,
yticklabels=,
font=scriptsize,
ticks=none,
extra x ticks=0,
extra y ticks=0,
]
draw (0,5) -- (10,0);
endaxis
endtikzpicture
endfigure
enddocument
My issue is not with creating a graph; I only put a simple line to demonstrate that the points are not lining up.
Does anyone know why this is happening? I cannot figure it out at all. Help would be much appreciated!
tikz-pgf pgfplots formatting axis
2
axis y line=middle
â Henri Menke
Sep 6 at 4:01
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
So I have been trying to graph a function for my economics class. My problem is that the "axis" that are created do not match up with actual points; for example, the point (0,5) will not be on the y-axis, it is shifted over.
Here is the code for my graph:
documentclassarticle
usepackagepgfplots
begindocument
beginfigure[ht]
centering
begintikzpicture[scale=1.5,line width=1pt]
beginaxis[
color= black,
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
axis equal,
axis x line=left,
axis y line=left,
disabledatascaling,
xticklabels=,
yticklabels=,
font=scriptsize,
ticks=none,
extra x ticks=0,
extra y ticks=0,
]
draw (0,5) -- (10,0);
endaxis
endtikzpicture
endfigure
enddocument
My issue is not with creating a graph; I only put a simple line to demonstrate that the points are not lining up.
Does anyone know why this is happening? I cannot figure it out at all. Help would be much appreciated!
tikz-pgf pgfplots formatting axis
So I have been trying to graph a function for my economics class. My problem is that the "axis" that are created do not match up with actual points; for example, the point (0,5) will not be on the y-axis, it is shifted over.
Here is the code for my graph:
documentclassarticle
usepackagepgfplots
begindocument
beginfigure[ht]
centering
begintikzpicture[scale=1.5,line width=1pt]
beginaxis[
color= black,
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
axis equal,
axis x line=left,
axis y line=left,
disabledatascaling,
xticklabels=,
yticklabels=,
font=scriptsize,
ticks=none,
extra x ticks=0,
extra y ticks=0,
]
draw (0,5) -- (10,0);
endaxis
endtikzpicture
endfigure
enddocument
My issue is not with creating a graph; I only put a simple line to demonstrate that the points are not lining up.
Does anyone know why this is happening? I cannot figure it out at all. Help would be much appreciated!
tikz-pgf pgfplots formatting axis
tikz-pgf pgfplots formatting axis
edited Sep 6 at 5:00
Stefan Pinnow
18.8k83172
18.8k83172
asked Sep 6 at 4:00
Aiden Kenny
283
283
2
axis y line=middle
â Henri Menke
Sep 6 at 4:01
add a comment |Â
2
axis y line=middle
â Henri Menke
Sep 6 at 4:01
2
2
axis y line=middle
â Henri Menke
Sep 6 at 4:01
axis y line=middle
â Henri Menke
Sep 6 at 4:01
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
The problem is with the axis equal
line. axis equal
changes the axis limits automatically in order to make the plot fit in the specified height and width. You can see that it's changing the x-axis by commenting out the ticks=none
line - the 0 tick mark is not at the y axis.
I recommend removing the axis equal
line.
add a comment |Â
up vote
3
down vote
As David already pointed out in his answer this is because of the axis equal
option which changes the axis limits to fit the specified width
and height
of the axis
.
Another alternative would be to use the axis equal image
key, which changes either the width
or the height
.
If you always want to be sure that the axis lines are drawn at the zero coordinates, you should use axis lines=middle
instead of axis lines=left
, as Henri Menke already stated in the comment below the question.
(I also made some other comments to your code in my answer code, which you should have a look at. Just in case you weren't aware of this stuff.)
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
% % (use this `compat' level or higher so by default TikZ coordinates use
% % `axis cs:'. See comments below for more details.)
% pgfplotssetcompat=1.11
begindocument
begintikzpicture
beginaxis[
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
% ---------------------------------------------------------------------
% replace `axis equal' with `axis equal image'
% axis equal,
axis equal image,
% ---------------------------------------------------------------------
% % (if you want to be sure that the axis lines are drawn at the
% % zero coordinates, than you should use `axis lines=middle'.
% % Please note that then by default the zero ticklabels are not
% % drawn, because in general these would be written on "the other"
% % axis line. To make them appear nonetheless you could add
% % `hide obscured x ticks=false' (and similar for the y axis), as
% % are commented below the next commented option line.)
axis lines=left,
% axis lines=middle,
% hide obscured x ticks=false,
% hide obscured y ticks=false,
% % (if you comment `disabledatascaling' you also don't get the desired
% % result, because with the default `compat' level TikZ coordinates
% % by default don't use the axis coordinate system (`axis cs:'), but
% % the tikzpicture coordinate system (`cs:'). ...
% disabledatascaling,
]
% (... To overcome this issue you could either prepend all TikZ
% coordinates by `axis cs:' or use a `compat' value of 1.11 or higher)
draw [red,thick] ( 0,5) -- ( 10,0);
draw [green] (axis cs:0,5) -- (axis cs:10,0);
endaxis
endtikzpicture
enddocument
Thank you so much! I will play around with this more, but you are right, I do not know about all of the small details, and I have a lot more control over how my picture looks now! I appreciate the help so much.
â Aiden Kenny
Sep 12 at 19:13
1
Glad that I could help. If you like my answer and it was helpful, please consider upvoting it (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark âÂÂ). Thank you.
â Stefan Pinnow
Sep 12 at 20:47
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
The problem is with the axis equal
line. axis equal
changes the axis limits automatically in order to make the plot fit in the specified height and width. You can see that it's changing the x-axis by commenting out the ticks=none
line - the 0 tick mark is not at the y axis.
I recommend removing the axis equal
line.
add a comment |Â
up vote
3
down vote
The problem is with the axis equal
line. axis equal
changes the axis limits automatically in order to make the plot fit in the specified height and width. You can see that it's changing the x-axis by commenting out the ticks=none
line - the 0 tick mark is not at the y axis.
I recommend removing the axis equal
line.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
The problem is with the axis equal
line. axis equal
changes the axis limits automatically in order to make the plot fit in the specified height and width. You can see that it's changing the x-axis by commenting out the ticks=none
line - the 0 tick mark is not at the y axis.
I recommend removing the axis equal
line.
The problem is with the axis equal
line. axis equal
changes the axis limits automatically in order to make the plot fit in the specified height and width. You can see that it's changing the x-axis by commenting out the ticks=none
line - the 0 tick mark is not at the y axis.
I recommend removing the axis equal
line.
answered Sep 6 at 4:06
David Scott
434
434
add a comment |Â
add a comment |Â
up vote
3
down vote
As David already pointed out in his answer this is because of the axis equal
option which changes the axis limits to fit the specified width
and height
of the axis
.
Another alternative would be to use the axis equal image
key, which changes either the width
or the height
.
If you always want to be sure that the axis lines are drawn at the zero coordinates, you should use axis lines=middle
instead of axis lines=left
, as Henri Menke already stated in the comment below the question.
(I also made some other comments to your code in my answer code, which you should have a look at. Just in case you weren't aware of this stuff.)
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
% % (use this `compat' level or higher so by default TikZ coordinates use
% % `axis cs:'. See comments below for more details.)
% pgfplotssetcompat=1.11
begindocument
begintikzpicture
beginaxis[
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
% ---------------------------------------------------------------------
% replace `axis equal' with `axis equal image'
% axis equal,
axis equal image,
% ---------------------------------------------------------------------
% % (if you want to be sure that the axis lines are drawn at the
% % zero coordinates, than you should use `axis lines=middle'.
% % Please note that then by default the zero ticklabels are not
% % drawn, because in general these would be written on "the other"
% % axis line. To make them appear nonetheless you could add
% % `hide obscured x ticks=false' (and similar for the y axis), as
% % are commented below the next commented option line.)
axis lines=left,
% axis lines=middle,
% hide obscured x ticks=false,
% hide obscured y ticks=false,
% % (if you comment `disabledatascaling' you also don't get the desired
% % result, because with the default `compat' level TikZ coordinates
% % by default don't use the axis coordinate system (`axis cs:'), but
% % the tikzpicture coordinate system (`cs:'). ...
% disabledatascaling,
]
% (... To overcome this issue you could either prepend all TikZ
% coordinates by `axis cs:' or use a `compat' value of 1.11 or higher)
draw [red,thick] ( 0,5) -- ( 10,0);
draw [green] (axis cs:0,5) -- (axis cs:10,0);
endaxis
endtikzpicture
enddocument
Thank you so much! I will play around with this more, but you are right, I do not know about all of the small details, and I have a lot more control over how my picture looks now! I appreciate the help so much.
â Aiden Kenny
Sep 12 at 19:13
1
Glad that I could help. If you like my answer and it was helpful, please consider upvoting it (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark âÂÂ). Thank you.
â Stefan Pinnow
Sep 12 at 20:47
add a comment |Â
up vote
3
down vote
As David already pointed out in his answer this is because of the axis equal
option which changes the axis limits to fit the specified width
and height
of the axis
.
Another alternative would be to use the axis equal image
key, which changes either the width
or the height
.
If you always want to be sure that the axis lines are drawn at the zero coordinates, you should use axis lines=middle
instead of axis lines=left
, as Henri Menke already stated in the comment below the question.
(I also made some other comments to your code in my answer code, which you should have a look at. Just in case you weren't aware of this stuff.)
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
% % (use this `compat' level or higher so by default TikZ coordinates use
% % `axis cs:'. See comments below for more details.)
% pgfplotssetcompat=1.11
begindocument
begintikzpicture
beginaxis[
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
% ---------------------------------------------------------------------
% replace `axis equal' with `axis equal image'
% axis equal,
axis equal image,
% ---------------------------------------------------------------------
% % (if you want to be sure that the axis lines are drawn at the
% % zero coordinates, than you should use `axis lines=middle'.
% % Please note that then by default the zero ticklabels are not
% % drawn, because in general these would be written on "the other"
% % axis line. To make them appear nonetheless you could add
% % `hide obscured x ticks=false' (and similar for the y axis), as
% % are commented below the next commented option line.)
axis lines=left,
% axis lines=middle,
% hide obscured x ticks=false,
% hide obscured y ticks=false,
% % (if you comment `disabledatascaling' you also don't get the desired
% % result, because with the default `compat' level TikZ coordinates
% % by default don't use the axis coordinate system (`axis cs:'), but
% % the tikzpicture coordinate system (`cs:'). ...
% disabledatascaling,
]
% (... To overcome this issue you could either prepend all TikZ
% coordinates by `axis cs:' or use a `compat' value of 1.11 or higher)
draw [red,thick] ( 0,5) -- ( 10,0);
draw [green] (axis cs:0,5) -- (axis cs:10,0);
endaxis
endtikzpicture
enddocument
Thank you so much! I will play around with this more, but you are right, I do not know about all of the small details, and I have a lot more control over how my picture looks now! I appreciate the help so much.
â Aiden Kenny
Sep 12 at 19:13
1
Glad that I could help. If you like my answer and it was helpful, please consider upvoting it (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark âÂÂ). Thank you.
â Stefan Pinnow
Sep 12 at 20:47
add a comment |Â
up vote
3
down vote
up vote
3
down vote
As David already pointed out in his answer this is because of the axis equal
option which changes the axis limits to fit the specified width
and height
of the axis
.
Another alternative would be to use the axis equal image
key, which changes either the width
or the height
.
If you always want to be sure that the axis lines are drawn at the zero coordinates, you should use axis lines=middle
instead of axis lines=left
, as Henri Menke already stated in the comment below the question.
(I also made some other comments to your code in my answer code, which you should have a look at. Just in case you weren't aware of this stuff.)
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
% % (use this `compat' level or higher so by default TikZ coordinates use
% % `axis cs:'. See comments below for more details.)
% pgfplotssetcompat=1.11
begindocument
begintikzpicture
beginaxis[
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
% ---------------------------------------------------------------------
% replace `axis equal' with `axis equal image'
% axis equal,
axis equal image,
% ---------------------------------------------------------------------
% % (if you want to be sure that the axis lines are drawn at the
% % zero coordinates, than you should use `axis lines=middle'.
% % Please note that then by default the zero ticklabels are not
% % drawn, because in general these would be written on "the other"
% % axis line. To make them appear nonetheless you could add
% % `hide obscured x ticks=false' (and similar for the y axis), as
% % are commented below the next commented option line.)
axis lines=left,
% axis lines=middle,
% hide obscured x ticks=false,
% hide obscured y ticks=false,
% % (if you comment `disabledatascaling' you also don't get the desired
% % result, because with the default `compat' level TikZ coordinates
% % by default don't use the axis coordinate system (`axis cs:'), but
% % the tikzpicture coordinate system (`cs:'). ...
% disabledatascaling,
]
% (... To overcome this issue you could either prepend all TikZ
% coordinates by `axis cs:' or use a `compat' value of 1.11 or higher)
draw [red,thick] ( 0,5) -- ( 10,0);
draw [green] (axis cs:0,5) -- (axis cs:10,0);
endaxis
endtikzpicture
enddocument
As David already pointed out in his answer this is because of the axis equal
option which changes the axis limits to fit the specified width
and height
of the axis
.
Another alternative would be to use the axis equal image
key, which changes either the width
or the height
.
If you always want to be sure that the axis lines are drawn at the zero coordinates, you should use axis lines=middle
instead of axis lines=left
, as Henri Menke already stated in the comment below the question.
(I also made some other comments to your code in my answer code, which you should have a look at. Just in case you weren't aware of this stuff.)
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
% % (use this `compat' level or higher so by default TikZ coordinates use
% % `axis cs:'. See comments below for more details.)
% pgfplotssetcompat=1.11
begindocument
begintikzpicture
beginaxis[
xmin=0,
xmax=19.5,
ymin=0,
ymax=19.5,
% ---------------------------------------------------------------------
% replace `axis equal' with `axis equal image'
% axis equal,
axis equal image,
% ---------------------------------------------------------------------
% % (if you want to be sure that the axis lines are drawn at the
% % zero coordinates, than you should use `axis lines=middle'.
% % Please note that then by default the zero ticklabels are not
% % drawn, because in general these would be written on "the other"
% % axis line. To make them appear nonetheless you could add
% % `hide obscured x ticks=false' (and similar for the y axis), as
% % are commented below the next commented option line.)
axis lines=left,
% axis lines=middle,
% hide obscured x ticks=false,
% hide obscured y ticks=false,
% % (if you comment `disabledatascaling' you also don't get the desired
% % result, because with the default `compat' level TikZ coordinates
% % by default don't use the axis coordinate system (`axis cs:'), but
% % the tikzpicture coordinate system (`cs:'). ...
% disabledatascaling,
]
% (... To overcome this issue you could either prepend all TikZ
% coordinates by `axis cs:' or use a `compat' value of 1.11 or higher)
draw [red,thick] ( 0,5) -- ( 10,0);
draw [green] (axis cs:0,5) -- (axis cs:10,0);
endaxis
endtikzpicture
enddocument
edited Sep 12 at 20:45
answered Sep 6 at 7:25
Stefan Pinnow
18.8k83172
18.8k83172
Thank you so much! I will play around with this more, but you are right, I do not know about all of the small details, and I have a lot more control over how my picture looks now! I appreciate the help so much.
â Aiden Kenny
Sep 12 at 19:13
1
Glad that I could help. If you like my answer and it was helpful, please consider upvoting it (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark âÂÂ). Thank you.
â Stefan Pinnow
Sep 12 at 20:47
add a comment |Â
Thank you so much! I will play around with this more, but you are right, I do not know about all of the small details, and I have a lot more control over how my picture looks now! I appreciate the help so much.
â Aiden Kenny
Sep 12 at 19:13
1
Glad that I could help. If you like my answer and it was helpful, please consider upvoting it (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark âÂÂ). Thank you.
â Stefan Pinnow
Sep 12 at 20:47
Thank you so much! I will play around with this more, but you are right, I do not know about all of the small details, and I have a lot more control over how my picture looks now! I appreciate the help so much.
â Aiden Kenny
Sep 12 at 19:13
Thank you so much! I will play around with this more, but you are right, I do not know about all of the small details, and I have a lot more control over how my picture looks now! I appreciate the help so much.
â Aiden Kenny
Sep 12 at 19:13
1
1
Glad that I could help. If you like my answer and it was helpful, please consider upvoting it (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark âÂÂ). Thank you.
â Stefan Pinnow
Sep 12 at 20:47
Glad that I could help. If you like my answer and it was helpful, please consider upvoting it (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark âÂÂ). Thank you.
â Stefan Pinnow
Sep 12 at 20:47
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f449599%2fissue-with-graphing-points%23new-answer', 'question_page');
);
Post as a guest
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
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
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
2
axis y line=middle
â Henri Menke
Sep 6 at 4:01