Put grid below plot in pgfplotspgfplots: How to set “axis on top” only for abscissa and ordinate, but not...

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

How is the relation "the smallest element is the same" reflexive?

cryptic clue: mammal sounds like relative consumer (8)

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

What typically incentivizes a professor to change jobs to a lower ranking university?

Can I make popcorn with any corn?

Why is the design of haulage companies so “special”?

Why does apt-get install python3 with a trailing hyphen remove a lot of packages?

Is there really no realistic way for a skeleton monster to move around without magic?

"which" command doesn't work / path of Safari?

Can a German sentence have two subjects?

How can bays and straits be determined in a procedurally generated map?

How to make payment on the internet without leaving a money trail?

Is there a familial term for apples and pears?

Why is an old chain unsafe?

Why CLRS example on residual networks does not follows its formula?

Non-Jewish family in an Orthodox Jewish Wedding

Email Account under attack (really) - anything I can do?

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

How to use Pandas to get the count of every combination inclusive

What would happen to a modern skyscraper if it rains micro blackholes?

Concept of linear mappings are confusing me

What does "enim et" mean?



Put grid below plot in pgfplots


pgfplots: How to set “axis on top” only for abscissa and ordinate, but not for grid?How to paint plot background below grid lines?pgfplots: “axis on top” will cross out ybar value nodes?PGFPlots how can I hide extra y tick marks?set minor grid values in pgfplotsHow do i get the x axis on top but keep a line on the bottomEngineering notation (scientific) as tick labels with pgfplots (maybe via siunitx)?Remove tick marks on only one axis in pgfplotsHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?Show mark labels near marks and not centered in ybar interaval graphpgfplots layer issuepgfplots: percentage in matrix plotCenter the axes in the coordinate origin













5















In a plot with pgfplots I would like to draw, from background to foreground, in the following order:




  1. (background) grid;

  2. (intermediate layer) plot;

  3. (foreground) axis.


As specified in this answer,




Adding axis on top to the axis options means axis lines, ticks and
grids are printed on top of the stuff inside the environment.




So, this is not the correct option for this. This code



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[/pgfplots/layers/Bowpark,
width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30}]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


doesn't work neither (plot is above grid, but also above the axis). I used addplot[blue, samples = 100] {x^2}; instead of addplot[samples = 100] {x^(1/2)}; to better highlight the superposition of the plot, the grid and the axis.



enter image description here



enter image description here



What's wrong? Note that also trying



pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,main,axis grid,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}


(switched the order of main and axis grid) produces the same output.



Maybe something in my configuration ignores the layers order?










share|improve this question




















  • 1





    The easiest way is probably to use axis on top but draw the grid by hand, behind the plot.

    – Henri Menke
    Oct 26 '18 at 14:37











  • @HenriMenke As far as I understood, the fact that axis and grid go together, complicates the problem. Having several plots with different axis max and min values would make quite troublesome also to draw by hand the grid each time.

    – BowPark
    Oct 26 '18 at 14:41


















5















In a plot with pgfplots I would like to draw, from background to foreground, in the following order:




  1. (background) grid;

  2. (intermediate layer) plot;

  3. (foreground) axis.


As specified in this answer,




Adding axis on top to the axis options means axis lines, ticks and
grids are printed on top of the stuff inside the environment.




So, this is not the correct option for this. This code



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[/pgfplots/layers/Bowpark,
width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30}]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


doesn't work neither (plot is above grid, but also above the axis). I used addplot[blue, samples = 100] {x^2}; instead of addplot[samples = 100] {x^(1/2)}; to better highlight the superposition of the plot, the grid and the axis.



enter image description here



enter image description here



What's wrong? Note that also trying



pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,main,axis grid,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}


(switched the order of main and axis grid) produces the same output.



Maybe something in my configuration ignores the layers order?










share|improve this question




















  • 1





    The easiest way is probably to use axis on top but draw the grid by hand, behind the plot.

    – Henri Menke
    Oct 26 '18 at 14:37











  • @HenriMenke As far as I understood, the fact that axis and grid go together, complicates the problem. Having several plots with different axis max and min values would make quite troublesome also to draw by hand the grid each time.

    – BowPark
    Oct 26 '18 at 14:41
















5












5








5








In a plot with pgfplots I would like to draw, from background to foreground, in the following order:




  1. (background) grid;

  2. (intermediate layer) plot;

  3. (foreground) axis.


As specified in this answer,




Adding axis on top to the axis options means axis lines, ticks and
grids are printed on top of the stuff inside the environment.




So, this is not the correct option for this. This code



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[/pgfplots/layers/Bowpark,
width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30}]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


doesn't work neither (plot is above grid, but also above the axis). I used addplot[blue, samples = 100] {x^2}; instead of addplot[samples = 100] {x^(1/2)}; to better highlight the superposition of the plot, the grid and the axis.



enter image description here



enter image description here



What's wrong? Note that also trying



pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,main,axis grid,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}


(switched the order of main and axis grid) produces the same output.



Maybe something in my configuration ignores the layers order?










share|improve this question
















In a plot with pgfplots I would like to draw, from background to foreground, in the following order:




  1. (background) grid;

  2. (intermediate layer) plot;

  3. (foreground) axis.


As specified in this answer,




Adding axis on top to the axis options means axis lines, ticks and
grids are printed on top of the stuff inside the environment.




So, this is not the correct option for this. This code



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[/pgfplots/layers/Bowpark,
width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30}]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


doesn't work neither (plot is above grid, but also above the axis). I used addplot[blue, samples = 100] {x^2}; instead of addplot[samples = 100] {x^(1/2)}; to better highlight the superposition of the plot, the grid and the axis.



enter image description here



enter image description here



What's wrong? Note that also trying



pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,main,axis grid,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}


(switched the order of main and axis grid) produces the same output.



Maybe something in my configuration ignores the layers order?







tikz-pgf pgfplots






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 27 '18 at 13:12







BowPark

















asked Oct 26 '18 at 10:48









BowParkBowPark

52029




52029








  • 1





    The easiest way is probably to use axis on top but draw the grid by hand, behind the plot.

    – Henri Menke
    Oct 26 '18 at 14:37











  • @HenriMenke As far as I understood, the fact that axis and grid go together, complicates the problem. Having several plots with different axis max and min values would make quite troublesome also to draw by hand the grid each time.

    – BowPark
    Oct 26 '18 at 14:41
















  • 1





    The easiest way is probably to use axis on top but draw the grid by hand, behind the plot.

    – Henri Menke
    Oct 26 '18 at 14:37











  • @HenriMenke As far as I understood, the fact that axis and grid go together, complicates the problem. Having several plots with different axis max and min values would make quite troublesome also to draw by hand the grid each time.

    – BowPark
    Oct 26 '18 at 14:41










1




1





The easiest way is probably to use axis on top but draw the grid by hand, behind the plot.

– Henri Menke
Oct 26 '18 at 14:37





The easiest way is probably to use axis on top but draw the grid by hand, behind the plot.

– Henri Menke
Oct 26 '18 at 14:37













@HenriMenke As far as I understood, the fact that axis and grid go together, complicates the problem. Having several plots with different axis max and min values would make quite troublesome also to draw by hand the grid each time.

– BowPark
Oct 26 '18 at 14:41







@HenriMenke As far as I understood, the fact that axis and grid go together, complicates the problem. Having several plots with different axis max and min values would make quite troublesome also to draw by hand the grid each time.

– BowPark
Oct 26 '18 at 14:41












1 Answer
1






active

oldest

votes


















7














This is discussed at length in section 4.27 of the pgfplots manual. All I did is to define a new layer set based on axis on top in which I flip the order of axis grid and main.



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30},
set layers=Bowpark]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


enter image description here



EDIT: Fixed bug, I was too sloppy, sorry!






share|improve this answer


























  • +1. Very good. I'm deleting my answer. With of sincerity I have not seen well the screen.

    – Sebastiano
    Oct 27 '18 at 9:41











  • I suspect that something in my environment ignores the layers order. Please, check out my edited question for more details about your code. And anyway thank you

    – BowPark
    Oct 27 '18 at 13:06






  • 1





    @BowPark Yes, you're right, I was too sloppy. You need to say set layers=Bowpark to activate the layers. My bad!

    – marmot
    Oct 27 '18 at 16:13






  • 1





    Its a sign of a great marmot that they tidiy up after themselves :-)

    – KJO
    Oct 27 '18 at 16:26











  • Don't worry and thank you so much. It works exactly as in your image!

    – BowPark
    Oct 27 '18 at 17:13












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%2f456859%2fput-grid-below-plot-in-pgfplots%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









7














This is discussed at length in section 4.27 of the pgfplots manual. All I did is to define a new layer set based on axis on top in which I flip the order of axis grid and main.



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30},
set layers=Bowpark]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


enter image description here



EDIT: Fixed bug, I was too sloppy, sorry!






share|improve this answer


























  • +1. Very good. I'm deleting my answer. With of sincerity I have not seen well the screen.

    – Sebastiano
    Oct 27 '18 at 9:41











  • I suspect that something in my environment ignores the layers order. Please, check out my edited question for more details about your code. And anyway thank you

    – BowPark
    Oct 27 '18 at 13:06






  • 1





    @BowPark Yes, you're right, I was too sloppy. You need to say set layers=Bowpark to activate the layers. My bad!

    – marmot
    Oct 27 '18 at 16:13






  • 1





    Its a sign of a great marmot that they tidiy up after themselves :-)

    – KJO
    Oct 27 '18 at 16:26











  • Don't worry and thank you so much. It works exactly as in your image!

    – BowPark
    Oct 27 '18 at 17:13
















7














This is discussed at length in section 4.27 of the pgfplots manual. All I did is to define a new layer set based on axis on top in which I flip the order of axis grid and main.



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30},
set layers=Bowpark]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


enter image description here



EDIT: Fixed bug, I was too sloppy, sorry!






share|improve this answer


























  • +1. Very good. I'm deleting my answer. With of sincerity I have not seen well the screen.

    – Sebastiano
    Oct 27 '18 at 9:41











  • I suspect that something in my environment ignores the layers order. Please, check out my edited question for more details about your code. And anyway thank you

    – BowPark
    Oct 27 '18 at 13:06






  • 1





    @BowPark Yes, you're right, I was too sloppy. You need to say set layers=Bowpark to activate the layers. My bad!

    – marmot
    Oct 27 '18 at 16:13






  • 1





    Its a sign of a great marmot that they tidiy up after themselves :-)

    – KJO
    Oct 27 '18 at 16:26











  • Don't worry and thank you so much. It works exactly as in your image!

    – BowPark
    Oct 27 '18 at 17:13














7












7








7







This is discussed at length in section 4.27 of the pgfplots manual. All I did is to define a new layer set based on axis on top in which I flip the order of axis grid and main.



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30},
set layers=Bowpark]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


enter image description here



EDIT: Fixed bug, I was too sloppy, sorry!






share|improve this answer















This is discussed at length in section 4.27 of the pgfplots manual. All I did is to define a new layer set based on axis on top in which I flip the order of axis grid and main.



documentclass{article}
usepackage{pgfplots}
usetikzlibrary{shapes.geometric,arrows,arrows.meta}
pgfplotsset{
/pgfplots/layers/Bowpark/.define layer set={
axis background,axis grid,main,axis ticks,axis lines,axis tick labels,
axis descriptions,axis foreground
}{/pgfplots/layers/standard},
}

begin{document}

begin{tikzpicture}
begin{axis}[width=textwidth,
xmin=-0.5, xmax=6,
ymin=-0.5, ymax=4,
axis line style = thin,
axis lines=middle,
axis line style={-{Stealth[length=2.5mm]}},
thick,
grid=major, grid style={dashed,gray!30},
set layers=Bowpark]

addplot[blue, samples = 100] {x^2};

end{axis}
end{tikzpicture}

end{document}


enter image description here



EDIT: Fixed bug, I was too sloppy, sorry!







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 27 '18 at 16:12

























answered Oct 26 '18 at 14:45









marmotmarmot

116k5147277




116k5147277













  • +1. Very good. I'm deleting my answer. With of sincerity I have not seen well the screen.

    – Sebastiano
    Oct 27 '18 at 9:41











  • I suspect that something in my environment ignores the layers order. Please, check out my edited question for more details about your code. And anyway thank you

    – BowPark
    Oct 27 '18 at 13:06






  • 1





    @BowPark Yes, you're right, I was too sloppy. You need to say set layers=Bowpark to activate the layers. My bad!

    – marmot
    Oct 27 '18 at 16:13






  • 1





    Its a sign of a great marmot that they tidiy up after themselves :-)

    – KJO
    Oct 27 '18 at 16:26











  • Don't worry and thank you so much. It works exactly as in your image!

    – BowPark
    Oct 27 '18 at 17:13



















  • +1. Very good. I'm deleting my answer. With of sincerity I have not seen well the screen.

    – Sebastiano
    Oct 27 '18 at 9:41











  • I suspect that something in my environment ignores the layers order. Please, check out my edited question for more details about your code. And anyway thank you

    – BowPark
    Oct 27 '18 at 13:06






  • 1





    @BowPark Yes, you're right, I was too sloppy. You need to say set layers=Bowpark to activate the layers. My bad!

    – marmot
    Oct 27 '18 at 16:13






  • 1





    Its a sign of a great marmot that they tidiy up after themselves :-)

    – KJO
    Oct 27 '18 at 16:26











  • Don't worry and thank you so much. It works exactly as in your image!

    – BowPark
    Oct 27 '18 at 17:13

















+1. Very good. I'm deleting my answer. With of sincerity I have not seen well the screen.

– Sebastiano
Oct 27 '18 at 9:41





+1. Very good. I'm deleting my answer. With of sincerity I have not seen well the screen.

– Sebastiano
Oct 27 '18 at 9:41













I suspect that something in my environment ignores the layers order. Please, check out my edited question for more details about your code. And anyway thank you

– BowPark
Oct 27 '18 at 13:06





I suspect that something in my environment ignores the layers order. Please, check out my edited question for more details about your code. And anyway thank you

– BowPark
Oct 27 '18 at 13:06




1




1





@BowPark Yes, you're right, I was too sloppy. You need to say set layers=Bowpark to activate the layers. My bad!

– marmot
Oct 27 '18 at 16:13





@BowPark Yes, you're right, I was too sloppy. You need to say set layers=Bowpark to activate the layers. My bad!

– marmot
Oct 27 '18 at 16:13




1




1





Its a sign of a great marmot that they tidiy up after themselves :-)

– KJO
Oct 27 '18 at 16:26





Its a sign of a great marmot that they tidiy up after themselves :-)

– KJO
Oct 27 '18 at 16:26













Don't worry and thank you so much. It works exactly as in your image!

– BowPark
Oct 27 '18 at 17:13





Don't worry and thank you so much. It works exactly as in your image!

– BowPark
Oct 27 '18 at 17:13


















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%2f456859%2fput-grid-below-plot-in-pgfplots%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

Paper upload error, “Upload failed: The top margin is 0.715 in on page 3, which is below the required...

Emraan Hashmi Filmografia | Linki zewnętrzne | Menu nawigacyjneGulshan GroverGulshan...

How can I write this formula?newline and italics added with leqWhy does widehat behave differently if I...