Scale tikz arrow length relative to its starting point
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}

tikz-pgf scale
add a comment |
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}

tikz-pgf scale
add a comment |
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}

tikz-pgf scale
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}

tikz-pgf scale
tikz-pgf scale
edited Jan 25 at 17:16
user3435407
asked Jan 25 at 17:02
user3435407user3435407
1274
1274
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If I understand you correctly, you want to scale the length of the arrow down. This suggests to
- switch to relative coordinates, i.e. to replace
(0,2) -- (4,4)by(0,2) -- ++ (4,2), and then to - 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}

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%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
If I understand you correctly, you want to scale the length of the arrow down. This suggests to
- switch to relative coordinates, i.e. to replace
(0,2) -- (4,4)by(0,2) -- ++ (4,2), and then to - 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}

add a comment |
If I understand you correctly, you want to scale the length of the arrow down. This suggests to
- switch to relative coordinates, i.e. to replace
(0,2) -- (4,4)by(0,2) -- ++ (4,2), and then to - 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}

add a comment |
If I understand you correctly, you want to scale the length of the arrow down. This suggests to
- switch to relative coordinates, i.e. to replace
(0,2) -- (4,4)by(0,2) -- ++ (4,2), and then to - 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}

If I understand you correctly, you want to scale the length of the arrow down. This suggests to
- switch to relative coordinates, i.e. to replace
(0,2) -- (4,4)by(0,2) -- ++ (4,2), and then to - 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}

answered Jan 25 at 17:06
marmotmarmot
96.6k4111213
96.6k4111213
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%2f471864%2fscale-tikz-arrow-length-relative-to-its-starting-point%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