Set aspect ratio on 2D pgfplots plot
I would like to set the aspect ratio of a pgfplots plots without explicitly specifying width and height (i.e., leaving them default). For 3D plots, there is plot box ratio
; for 2D plots, I tried playing with axisdefaultheight
, but it just blows the thing out of proportion:
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
width=2axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
end{tikzpicture}
end{document}
The option unit vector ratio
takes into account the actual axis limits, so after a bit of computation, this could be used. I'm looking for a setting on the axis lengths only, though.
Any hints?
tikz-pgf pgfplots
add a comment |
I would like to set the aspect ratio of a pgfplots plots without explicitly specifying width and height (i.e., leaving them default). For 3D plots, there is plot box ratio
; for 2D plots, I tried playing with axisdefaultheight
, but it just blows the thing out of proportion:
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
width=2axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
end{tikzpicture}
end{document}
The option unit vector ratio
takes into account the actual axis limits, so after a bit of computation, this could be used. I'm looking for a setting on the axis lengths only, though.
Any hints?
tikz-pgf pgfplots
I think you can just addunit vector ratio = {16 3}
.
– Raaja
Mar 18 at 11:05
add a comment |
I would like to set the aspect ratio of a pgfplots plots without explicitly specifying width and height (i.e., leaving them default). For 3D plots, there is plot box ratio
; for 2D plots, I tried playing with axisdefaultheight
, but it just blows the thing out of proportion:
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
width=2axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
end{tikzpicture}
end{document}
The option unit vector ratio
takes into account the actual axis limits, so after a bit of computation, this could be used. I'm looking for a setting on the axis lengths only, though.
Any hints?
tikz-pgf pgfplots
I would like to set the aspect ratio of a pgfplots plots without explicitly specifying width and height (i.e., leaving them default). For 3D plots, there is plot box ratio
; for 2D plots, I tried playing with axisdefaultheight
, but it just blows the thing out of proportion:
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
width=2axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
end{tikzpicture}
end{document}
The option unit vector ratio
takes into account the actual axis limits, so after a bit of computation, this could be used. I'm looking for a setting on the axis lengths only, though.
Any hints?
tikz-pgf pgfplots
tikz-pgf pgfplots
edited Mar 18 at 11:59
Nico Schlömer
asked Mar 18 at 10:46
Nico SchlömerNico Schlömer
2,07431836
2,07431836
I think you can just addunit vector ratio = {16 3}
.
– Raaja
Mar 18 at 11:05
add a comment |
I think you can just addunit vector ratio = {16 3}
.
– Raaja
Mar 18 at 11:05
I think you can just add
unit vector ratio = {16 3}
.– Raaja
Mar 18 at 11:05
I think you can just add
unit vector ratio = {16 3}
.– Raaja
Mar 18 at 11:05
add a comment |
1 Answer
1
active
oldest
votes
axisdefaultheight
is not a length but just a macro, which is why 2axisdefaultheight
does not work, but 2*axisdefaultheight
works. But then it is probably the simplest option to specify both the width and height.
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
height=axisdefaultheight,
width=2*axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
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%2f480058%2fset-aspect-ratio-on-2d-pgfplots-plot%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
axisdefaultheight
is not a length but just a macro, which is why 2axisdefaultheight
does not work, but 2*axisdefaultheight
works. But then it is probably the simplest option to specify both the width and height.
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
height=axisdefaultheight,
width=2*axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
end{tikzpicture}
end{document}
add a comment |
axisdefaultheight
is not a length but just a macro, which is why 2axisdefaultheight
does not work, but 2*axisdefaultheight
works. But then it is probably the simplest option to specify both the width and height.
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
height=axisdefaultheight,
width=2*axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
end{tikzpicture}
end{document}
add a comment |
axisdefaultheight
is not a length but just a macro, which is why 2axisdefaultheight
does not work, but 2*axisdefaultheight
works. But then it is probably the simplest option to specify both the width and height.
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
height=axisdefaultheight,
width=2*axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
end{tikzpicture}
end{document}
axisdefaultheight
is not a length but just a macro, which is why 2axisdefaultheight
does not work, but 2*axisdefaultheight
works. But then it is probably the simplest option to specify both the width and height.
documentclass{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
height=axisdefaultheight,
width=2*axisdefaultheight
]
addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
end{axis}
end{tikzpicture}
end{document}
answered Mar 18 at 14:32
marmotmarmot
112k5143268
112k5143268
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%2f480058%2fset-aspect-ratio-on-2d-pgfplots-plot%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
I think you can just add
unit vector ratio = {16 3}
.– Raaja
Mar 18 at 11:05