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
New contributor
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
New contributor
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
New contributor
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
New contributor
edited Sep 6 at 5:00
Stefan Pinnow
18.8k83172
18.8k83172
New contributor
asked Sep 6 at 4:00
Aiden Kenny
161
161
New contributor
New contributor
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
2
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 than 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
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
2
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 than 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
add a comment |Â
up vote
2
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 than 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
add a comment |Â
up vote
2
down vote
up vote
2
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 than 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 than 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
answered Sep 6 at 7:25
Stefan Pinnow
18.8k83172
18.8k83172
add a comment |Â
add a comment |Â
Aiden Kenny is a new contributor. Be nice, and check out our Code of Conduct.
Aiden Kenny is a new contributor. Be nice, and check out our Code of Conduct.
Aiden Kenny is a new contributor. Be nice, and check out our Code of Conduct.
Aiden Kenny is a new contributor. Be nice, and check out our Code of Conduct.
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