How to use addplot with “draw = none†and marks?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I would like to record a plot's style to the legend without actually drawing the plot.
I know how to do this when the plot style does not have marks, as shown in the first example below.
However, when the plot has marks, as in the second example, the marks still get drawn even though draw=none.
Is there anyway to suppress the marks, while still ensuring that the style gets propagated to the legend? If not, any suggested workarounds?
MWE:
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
addplot [blue, mark=*, domain=0:3.5, draw=none] 15 - .5*x;
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
This produces:
What I want is a blank plot with just the legend.
tikz-pgf pgfplots
add a comment |Â
up vote
3
down vote
favorite
I would like to record a plot's style to the legend without actually drawing the plot.
I know how to do this when the plot style does not have marks, as shown in the first example below.
However, when the plot has marks, as in the second example, the marks still get drawn even though draw=none.
Is there anyway to suppress the marks, while still ensuring that the style gets propagated to the legend? If not, any suggested workarounds?
MWE:
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
addplot [blue, mark=*, domain=0:3.5, draw=none] 15 - .5*x;
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
This produces:
What I want is a blank plot with just the legend.
tikz-pgf pgfplots
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I would like to record a plot's style to the legend without actually drawing the plot.
I know how to do this when the plot style does not have marks, as shown in the first example below.
However, when the plot has marks, as in the second example, the marks still get drawn even though draw=none.
Is there anyway to suppress the marks, while still ensuring that the style gets propagated to the legend? If not, any suggested workarounds?
MWE:
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
addplot [blue, mark=*, domain=0:3.5, draw=none] 15 - .5*x;
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
This produces:
What I want is a blank plot with just the legend.
tikz-pgf pgfplots
I would like to record a plot's style to the legend without actually drawing the plot.
I know how to do this when the plot style does not have marks, as shown in the first example below.
However, when the plot has marks, as in the second example, the marks still get drawn even though draw=none.
Is there anyway to suppress the marks, while still ensuring that the style gets propagated to the legend? If not, any suggested workarounds?
MWE:
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
addplot [blue, mark=*, domain=0:3.5, draw=none] 15 - .5*x;
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
This produces:
What I want is a blank plot with just the legend.
tikz-pgf pgfplots
asked Aug 21 at 19:18
evencoil
224137
224137
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
You can use addlegendimage
(in combination with addlegendentry
) to achieve what you want. Just give the option or key--values respectively to the commands argument as you would do to addplot
. Please note that at least one addplot
command is present so that the legend shows up.
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
begindocument
begintikzpicture
beginaxis
addlegendimageno markers,red
addlegendentryfirst plot
addlegendimageblue,mark=*,only marks
addlegendentrysecond plot
addplot [draw=none] x;
endaxis
endtikzpicture
enddocument
add a comment |Â
up vote
2
down vote
If you are willing to cheat, you could set xmin=0
and just plot samples at=-1
. I stress that this is a cheat, and of course won't work if you wan to use that empty plot for intersections or fillbetween
or the like.
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis[xmin=0,xmax=3.5]
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
%beginscope[opacity=0]
addplot [blue, mark=*, draw=none,samples at=-1] 15 - .5*x;
%endscope
%tikzsetopacity=1
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
You can use addlegendimage
(in combination with addlegendentry
) to achieve what you want. Just give the option or key--values respectively to the commands argument as you would do to addplot
. Please note that at least one addplot
command is present so that the legend shows up.
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
begindocument
begintikzpicture
beginaxis
addlegendimageno markers,red
addlegendentryfirst plot
addlegendimageblue,mark=*,only marks
addlegendentrysecond plot
addplot [draw=none] x;
endaxis
endtikzpicture
enddocument
add a comment |Â
up vote
4
down vote
accepted
You can use addlegendimage
(in combination with addlegendentry
) to achieve what you want. Just give the option or key--values respectively to the commands argument as you would do to addplot
. Please note that at least one addplot
command is present so that the legend shows up.
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
begindocument
begintikzpicture
beginaxis
addlegendimageno markers,red
addlegendentryfirst plot
addlegendimageblue,mark=*,only marks
addlegendentrysecond plot
addplot [draw=none] x;
endaxis
endtikzpicture
enddocument
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
You can use addlegendimage
(in combination with addlegendentry
) to achieve what you want. Just give the option or key--values respectively to the commands argument as you would do to addplot
. Please note that at least one addplot
command is present so that the legend shows up.
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
begindocument
begintikzpicture
beginaxis
addlegendimageno markers,red
addlegendentryfirst plot
addlegendimageblue,mark=*,only marks
addlegendentrysecond plot
addplot [draw=none] x;
endaxis
endtikzpicture
enddocument
You can use addlegendimage
(in combination with addlegendentry
) to achieve what you want. Just give the option or key--values respectively to the commands argument as you would do to addplot
. Please note that at least one addplot
command is present so that the legend shows up.
% used PGFPlots v1.16
documentclass[border=5pt]standalone
usepackagepgfplots
begindocument
begintikzpicture
beginaxis
addlegendimageno markers,red
addlegendentryfirst plot
addlegendimageblue,mark=*,only marks
addlegendentrysecond plot
addplot [draw=none] x;
endaxis
endtikzpicture
enddocument
answered Aug 21 at 19:45
Stefan Pinnow
18.7k83170
18.7k83170
add a comment |Â
add a comment |Â
up vote
2
down vote
If you are willing to cheat, you could set xmin=0
and just plot samples at=-1
. I stress that this is a cheat, and of course won't work if you wan to use that empty plot for intersections or fillbetween
or the like.
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis[xmin=0,xmax=3.5]
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
%beginscope[opacity=0]
addplot [blue, mark=*, draw=none,samples at=-1] 15 - .5*x;
%endscope
%tikzsetopacity=1
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
add a comment |Â
up vote
2
down vote
If you are willing to cheat, you could set xmin=0
and just plot samples at=-1
. I stress that this is a cheat, and of course won't work if you wan to use that empty plot for intersections or fillbetween
or the like.
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis[xmin=0,xmax=3.5]
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
%beginscope[opacity=0]
addplot [blue, mark=*, draw=none,samples at=-1] 15 - .5*x;
%endscope
%tikzsetopacity=1
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
add a comment |Â
up vote
2
down vote
up vote
2
down vote
If you are willing to cheat, you could set xmin=0
and just plot samples at=-1
. I stress that this is a cheat, and of course won't work if you wan to use that empty plot for intersections or fillbetween
or the like.
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis[xmin=0,xmax=3.5]
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
%beginscope[opacity=0]
addplot [blue, mark=*, draw=none,samples at=-1] 15 - .5*x;
%endscope
%tikzsetopacity=1
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
If you are willing to cheat, you could set xmin=0
and just plot samples at=-1
. I stress that this is a cheat, and of course won't work if you wan to use that empty plot for intersections or fillbetween
or the like.
documentclass[article]standalone
usepackagetikz
usepackagepgfplots
pgfplotssetcompat = newest % loads newest improved settings
begindocument
begintikzpicture
beginaxis[xmin=0,xmax=3.5]
% Use draw=none so that the plot is not drawn, but style is recorded to
% legend entry
addplot [red, domain=0:3.5, draw=none] 25*x^0.2;
addlegendentryfirst plot
% Would like to do the same thing with a mark
% But the mark still gets drawn!
%beginscope[opacity=0]
addplot [blue, mark=*, draw=none,samples at=-1] 15 - .5*x;
%endscope
%tikzsetopacity=1
addlegendentrysecond plot
endaxis
endtikzpicture
enddocument
answered Aug 21 at 19:41


marmot
55.4k460121
55.4k460121
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447046%2fhow-to-use-addplot-with-draw-none-and-marks%23new-answer', 'question_page');
);
Post as a guest
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
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
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