Adding points and their relative legend with tikz
The following code
begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
end{axis}
end{tikzpicture}
produces the picture below:
In the legend I'd like only one description for different kinds of point. For example, we have that the cases 10 and 15 are repeated two times. The correct picture should be that:
EDIT
However, the code:
begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
does not solve my problem:
tikz-pgf
add a comment |
The following code
begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
end{axis}
end{tikzpicture}
produces the picture below:
In the legend I'd like only one description for different kinds of point. For example, we have that the cases 10 and 15 are repeated two times. The correct picture should be that:
EDIT
However, the code:
begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
does not solve my problem:
tikz-pgf
How about invoking the respectiveaddlegendentry
only once instead of twice?
– marmot
7 hours ago
I've edited my post. Unfortunately I have another issue.
– Mark
6 hours ago
add a comment |
The following code
begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
end{axis}
end{tikzpicture}
produces the picture below:
In the legend I'd like only one description for different kinds of point. For example, we have that the cases 10 and 15 are repeated two times. The correct picture should be that:
EDIT
However, the code:
begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
does not solve my problem:
tikz-pgf
The following code
begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
end{axis}
end{tikzpicture}
produces the picture below:
In the legend I'd like only one description for different kinds of point. For example, we have that the cases 10 and 15 are repeated two times. The correct picture should be that:
EDIT
However, the code:
begin{tikzpicture}[scale=0.7]
begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
does not solve my problem:
tikz-pgf
tikz-pgf
edited 6 hours ago
Mark
asked 7 hours ago
MarkMark
23716
23716
How about invoking the respectiveaddlegendentry
only once instead of twice?
– marmot
7 hours ago
I've edited my post. Unfortunately I have another issue.
– Mark
6 hours ago
add a comment |
How about invoking the respectiveaddlegendentry
only once instead of twice?
– marmot
7 hours ago
I've edited my post. Unfortunately I have another issue.
– Mark
6 hours ago
How about invoking the respective
addlegendentry
only once instead of twice?– marmot
7 hours ago
How about invoking the respective
addlegendentry
only once instead of twice?– marmot
7 hours ago
I've edited my post. Unfortunately I have another issue.
– Mark
6 hours ago
I've edited my post. Unfortunately I have another issue.
– Mark
6 hours ago
add a comment |
1 Answer
1
active
oldest
votes
One should never forget about the option forget plot
, which allows you to disregard a plot for a legend. I added this to every other plot to obtain
documentclass[border=3.14mm,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x,forget plot] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o,forget plot] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square,forget plot] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
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%2f482825%2fadding-points-and-their-relative-legend-with-tikz%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
One should never forget about the option forget plot
, which allows you to disregard a plot for a legend. I added this to every other plot to obtain
documentclass[border=3.14mm,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x,forget plot] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o,forget plot] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square,forget plot] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
end{document}
add a comment |
One should never forget about the option forget plot
, which allows you to disregard a plot for a legend. I added this to every other plot to obtain
documentclass[border=3.14mm,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x,forget plot] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o,forget plot] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square,forget plot] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
end{document}
add a comment |
One should never forget about the option forget plot
, which allows you to disregard a plot for a legend. I added this to every other plot to obtain
documentclass[border=3.14mm,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x,forget plot] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o,forget plot] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square,forget plot] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
end{document}
One should never forget about the option forget plot
, which allows you to disregard a plot for a legend. I added this to every other plot to obtain
documentclass[border=3.14mm,tikz]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}
begin{axis}[scale=0.7,xlabel={$s$},ylabel={$c$},legend pos=south east]
addlegendimage{empty legend}
addlegendentry{}
addplot+[smooth,draw=black,mark=oplus] coordinates
{(0.3,0.275)};
addplot+[smooth,draw=black,mark=oplus,forget plot] coordinates
{(0.2,0.15)};
addlegendentry{$zeta=10$}
addplot+[smooth,draw=black,mark=x] coordinates
{(0.345743, 0.332178)};
addplot+[smooth,draw=black,mark=x,forget plot] coordinates
{(0.154257, 0.0928216)};
addlegendentry{$zeta=15$}
addplot+[smooth,draw=black,mark=o] coordinates
{(0.361803,0.352254)};
addplot+[smooth,draw=black,mark=o,forget plot] coordinates
{(0.138197, 0.0727458)};
addlegendentry{$zeta=20$}
addplot+[smooth,draw=black,mark=square] coordinates
{(0.370416, 0.36302)};
addplot+[smooth,draw=black,mark=square,forget plot] coordinates
{(0.129584, 0.0619801)};
addlegendentry{$zeta=25$}
end{axis}
end{tikzpicture}
end{document}
answered 5 hours ago
marmotmarmot
114k5145276
114k5145276
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%2f482825%2fadding-points-and-their-relative-legend-with-tikz%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
How about invoking the respective
addlegendentry
only once instead of twice?– marmot
7 hours ago
I've edited my post. Unfortunately I have another issue.
– Mark
6 hours ago