Issue with Graphing Points

The name of the pictureThe name of the pictureThe name of the pictureClash 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!










share|improve this question



















  • 2




    axis y line=middle
    – Henri Menke
    Sep 6 at 4:01















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!










share|improve this question



















  • 2




    axis y line=middle
    – Henri Menke
    Sep 6 at 4:01













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!










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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













  • 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











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.






share|improve this answer



























    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


    image showing the result of above code






    share|improve this answer






















    • 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










    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%2f449599%2fissue-with-graphing-points%23new-answer', 'question_page');

    );

    Post as a guest






























    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.






    share|improve this answer
























      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.






      share|improve this answer






















        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 6 at 4:06









        David Scott

        434




        434




















            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


            image showing the result of above code






            share|improve this answer






















            • 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














            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


            image showing the result of above code






            share|improve this answer






















            • 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












            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


            image showing the result of above code






            share|improve this answer














            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


            image showing the result of above code







            share|improve this answer














            share|improve this answer



            share|improve this answer








            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
















            • 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

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            這個網誌中的熱門文章

            Is there any way to eliminate the singular point to solve this integral by hand or by approximations?

            Why am i infinitely getting the same tweet with the Twitter Search API?

            Carbon dioxide