Score:1

PGFPLOTs incomplete grid, missing minor grid from both up and right sides

tn flag

I am making a file with pgfplot package and I want the grid to be with minor grids line complete from both sides, this is my trial:

\documentclass{standalone}

\usepackage{filecontents}
\usepackage{amsmath}
\usepackage{tkz-euclide}
\usepackage{makecell}
\usepackage{ifthen}
\usepackage{pgfmath}

\usetikzlibrary
{
    intersections, decorations.markings, angles,
    quotes, calc, arrows, arrows.meta,shapes.geometric
}

\usepackage{tikz-3dplot}

\usetikzlibrary{calc,intersections,arrows.meta}
\usepackage{hyperref}

\usepackage{tikz,tikzscale}
\usepackage{chemfig,chemformula}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}

\begin{document}
    

    \begin{filecontents}[overwrite]{fig2.tikz}
            \begin{tikzpicture}
                    
                    
                    
                    \pgfplotsset{
                            tick label style = {font = {\fontsize{11.25}{14}\selectfont}},
                            label style = {font = {\fontsize{11.25}{14}\selectfont}},
                            legend style = {font = {\fontsize{11.25}{14}\selectfont}},
                    }
                    
                    
                    \pgfplotsset{
                            outer axis line style={thick,},
                            grid = both,
                            tickwidth = 0.25cm,
                            set layers,
                    }
                    
                    
                    
                    \begin{axis}[anchor=origin,
                    grid=both,
                            grid style={thin, draw=gray!20},
                            major grid style={thin,draw=gray!50},
                            minor x tick num={3},
                            minor y tick num={4},
                            minor tick length=0pt,
                            xmin=-4,xmax=4,
                            ymin=-16,ymax=4,
                            xlabel={$x$},
                            xlabel style={at={(ticklabel* cs:1)},anchor=west},
                            ylabel={$y$},
                            ylabel style={at={(ticklabel* cs:1)},anchor=south},
                            xtick={-3,...,3},
                            tickwidth=0.25cm,
                            major tick style={black,thick},
                            extra x ticks={-4,0,4},
                            extra x tick labels={,0,},
                            extra x tick style={grid=both,black,
                                    major tick style={draw=none},
                                    tick label style={anchor=north east,xshift=-.5*\pgfkeysvalueof{/pgfplots/major tick length}},},
                            ytick={-14,-12,...,2},
                            extra y ticks={-16, 4},
                            extra y tick style={grid=both,major tick style={draw=none},},
                            extra y tick labels={},
                            axis lines=middle,
                            scale only axis,
                            axis line style={>={Stealth[scale=1.2]},<->,thick},
                            samples=1000]
                            
                            \addplot[domain=-4:4,draw=red,draw opacity=0.1,fill=red,fill opacity=0.1] {(3*x-2)*(x+3)}--(4,4)--(4,-16)--(-4,-16)--(-4,4)--cycle;
                            \addplot[domain=-4:4,draw=red,dashed] {(3*x-2)*(x+3)};
                            
                    
                    \end{axis}  
                    
                    
            \end{tikzpicture}
    \end{filecontents}
    
    \includegraphics[width=\linewidth]{fig2.tikz}
\end{document}

enter image description here

N0rbert avatar
zw flag
What is your Ubuntu version? Have you tried to consult with documentation at http://pgfplots.sourceforge.net/ ?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.