Scale tikz arrow length relative to its starting point












1















How can I scale an arrow so that the scaling is based on its starting point? In my example you see my problem. The black arrow should be scaled down by fifty percent to give the red arrow (as if (0,2) would be the origin). Instead I get the blue arrows, because scaling simply multiplies all the coordinate entries. I tried two methods with the same unwanted behavior. Do you know a simple way to get what I intended? Thanks!



documentclass{article}
usepackage{tikz}
begin{document}

begin{tikzpicture}
draw [thin,gray!40,step=1] (0,0) grid (4,4);
node at (-.3,-.3){(0,0)};
draw [->, very thick] (0,2) -- (4,4);
draw [->, thick, red] (0,2) -- (2,3);
draw [->, thick, blue, scale=.5] (0,2) -- (4,4);
begin{scope}[scale=.25]
draw [->, thick, blue] (0,2) -- (4,4);
end{scope}
end{tikzpicture}

end{document}


the example










share|improve this question





























    1















    How can I scale an arrow so that the scaling is based on its starting point? In my example you see my problem. The black arrow should be scaled down by fifty percent to give the red arrow (as if (0,2) would be the origin). Instead I get the blue arrows, because scaling simply multiplies all the coordinate entries. I tried two methods with the same unwanted behavior. Do you know a simple way to get what I intended? Thanks!



    documentclass{article}
    usepackage{tikz}
    begin{document}

    begin{tikzpicture}
    draw [thin,gray!40,step=1] (0,0) grid (4,4);
    node at (-.3,-.3){(0,0)};
    draw [->, very thick] (0,2) -- (4,4);
    draw [->, thick, red] (0,2) -- (2,3);
    draw [->, thick, blue, scale=.5] (0,2) -- (4,4);
    begin{scope}[scale=.25]
    draw [->, thick, blue] (0,2) -- (4,4);
    end{scope}
    end{tikzpicture}

    end{document}


    the example










    share|improve this question



























      1












      1








      1








      How can I scale an arrow so that the scaling is based on its starting point? In my example you see my problem. The black arrow should be scaled down by fifty percent to give the red arrow (as if (0,2) would be the origin). Instead I get the blue arrows, because scaling simply multiplies all the coordinate entries. I tried two methods with the same unwanted behavior. Do you know a simple way to get what I intended? Thanks!



      documentclass{article}
      usepackage{tikz}
      begin{document}

      begin{tikzpicture}
      draw [thin,gray!40,step=1] (0,0) grid (4,4);
      node at (-.3,-.3){(0,0)};
      draw [->, very thick] (0,2) -- (4,4);
      draw [->, thick, red] (0,2) -- (2,3);
      draw [->, thick, blue, scale=.5] (0,2) -- (4,4);
      begin{scope}[scale=.25]
      draw [->, thick, blue] (0,2) -- (4,4);
      end{scope}
      end{tikzpicture}

      end{document}


      the example










      share|improve this question
















      How can I scale an arrow so that the scaling is based on its starting point? In my example you see my problem. The black arrow should be scaled down by fifty percent to give the red arrow (as if (0,2) would be the origin). Instead I get the blue arrows, because scaling simply multiplies all the coordinate entries. I tried two methods with the same unwanted behavior. Do you know a simple way to get what I intended? Thanks!



      documentclass{article}
      usepackage{tikz}
      begin{document}

      begin{tikzpicture}
      draw [thin,gray!40,step=1] (0,0) grid (4,4);
      node at (-.3,-.3){(0,0)};
      draw [->, very thick] (0,2) -- (4,4);
      draw [->, thick, red] (0,2) -- (2,3);
      draw [->, thick, blue, scale=.5] (0,2) -- (4,4);
      begin{scope}[scale=.25]
      draw [->, thick, blue] (0,2) -- (4,4);
      end{scope}
      end{tikzpicture}

      end{document}


      the example







      tikz-pgf scale






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 25 at 17:16







      user3435407

















      asked Jan 25 at 17:02









      user3435407user3435407

      1274




      1274






















          1 Answer
          1






          active

          oldest

          votes


















          3














          If I understand you correctly, you want to scale the length of the arrow down. This suggests to




          1. switch to relative coordinates, i.e. to replace (0,2) -- (4,4) by (0,2) -- ++ (4,2), and then to

          2. just scale the ++ piece, e.g. (0,2) -- ++ ([scale=0.5]4,2).




          documentclass{article}
          usepackage{tikz}
          begin{document}

          begin{tikzpicture}
          draw [thin,gray!40,step=1] (0,0) grid (4,4);
          node at (-.3,-.3){(0,0)};
          draw [->, very thick] (0,2) -- (4,4);
          draw [->, thick, red] (0,2) -- (2,3);
          draw [->, thick, blue] (0,2) -- ++ ([scale=.5]4,2);
          draw [->, thick, purple] (0,2) -- ++ ([scale=.25]4,2);
          end{tikzpicture}

          end{document}


          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%2f471864%2fscale-tikz-arrow-length-relative-to-its-starting-point%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            If I understand you correctly, you want to scale the length of the arrow down. This suggests to




            1. switch to relative coordinates, i.e. to replace (0,2) -- (4,4) by (0,2) -- ++ (4,2), and then to

            2. just scale the ++ piece, e.g. (0,2) -- ++ ([scale=0.5]4,2).




            documentclass{article}
            usepackage{tikz}
            begin{document}

            begin{tikzpicture}
            draw [thin,gray!40,step=1] (0,0) grid (4,4);
            node at (-.3,-.3){(0,0)};
            draw [->, very thick] (0,2) -- (4,4);
            draw [->, thick, red] (0,2) -- (2,3);
            draw [->, thick, blue] (0,2) -- ++ ([scale=.5]4,2);
            draw [->, thick, purple] (0,2) -- ++ ([scale=.25]4,2);
            end{tikzpicture}

            end{document}


            enter image description here






            share|improve this answer




























              3














              If I understand you correctly, you want to scale the length of the arrow down. This suggests to




              1. switch to relative coordinates, i.e. to replace (0,2) -- (4,4) by (0,2) -- ++ (4,2), and then to

              2. just scale the ++ piece, e.g. (0,2) -- ++ ([scale=0.5]4,2).




              documentclass{article}
              usepackage{tikz}
              begin{document}

              begin{tikzpicture}
              draw [thin,gray!40,step=1] (0,0) grid (4,4);
              node at (-.3,-.3){(0,0)};
              draw [->, very thick] (0,2) -- (4,4);
              draw [->, thick, red] (0,2) -- (2,3);
              draw [->, thick, blue] (0,2) -- ++ ([scale=.5]4,2);
              draw [->, thick, purple] (0,2) -- ++ ([scale=.25]4,2);
              end{tikzpicture}

              end{document}


              enter image description here






              share|improve this answer


























                3












                3








                3







                If I understand you correctly, you want to scale the length of the arrow down. This suggests to




                1. switch to relative coordinates, i.e. to replace (0,2) -- (4,4) by (0,2) -- ++ (4,2), and then to

                2. just scale the ++ piece, e.g. (0,2) -- ++ ([scale=0.5]4,2).




                documentclass{article}
                usepackage{tikz}
                begin{document}

                begin{tikzpicture}
                draw [thin,gray!40,step=1] (0,0) grid (4,4);
                node at (-.3,-.3){(0,0)};
                draw [->, very thick] (0,2) -- (4,4);
                draw [->, thick, red] (0,2) -- (2,3);
                draw [->, thick, blue] (0,2) -- ++ ([scale=.5]4,2);
                draw [->, thick, purple] (0,2) -- ++ ([scale=.25]4,2);
                end{tikzpicture}

                end{document}


                enter image description here






                share|improve this answer













                If I understand you correctly, you want to scale the length of the arrow down. This suggests to




                1. switch to relative coordinates, i.e. to replace (0,2) -- (4,4) by (0,2) -- ++ (4,2), and then to

                2. just scale the ++ piece, e.g. (0,2) -- ++ ([scale=0.5]4,2).




                documentclass{article}
                usepackage{tikz}
                begin{document}

                begin{tikzpicture}
                draw [thin,gray!40,step=1] (0,0) grid (4,4);
                node at (-.3,-.3){(0,0)};
                draw [->, very thick] (0,2) -- (4,4);
                draw [->, thick, red] (0,2) -- (2,3);
                draw [->, thick, blue] (0,2) -- ++ ([scale=.5]4,2);
                draw [->, thick, purple] (0,2) -- ++ ([scale=.25]4,2);
                end{tikzpicture}

                end{document}


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 25 at 17:06









                marmotmarmot

                96.6k4111213




                96.6k4111213






























                    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%2f471864%2fscale-tikz-arrow-length-relative-to-its-starting-point%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 send String Array data to Server using php in android

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Is anime1.com a legal site for watching anime?