将白色背景延伸到图表之外

将白色背景延伸到图表之外

我想扩展白色背景,使其位于箭头下方。

*灰色矩形只是为了对比看看背景停止的位置。

在此处输入图片描述

我根据同一个模板生成了很多图表。因此,参数中包含此类信息非常重要。

我查看了 pgfplots 手册,但没有找到信息。有什么想法吗?使用 tikzset 而不是 pgfplotsset?

 %%%%%%%%%%%%%%%%%% INTRODUCTION %%%%%%%%%%%%%%%%%%
\documentclass[border=10pt]{standalone}
%%%%%%%%%%%%%%%%%% INPUT %%%%%%%%%%%%%%%%%%
%\input{preamble.tex}
%\input{parameters.tex}
%%%%%%%%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%%%%%%
\usepackage{tikz, tkz-euclide}%  permet de dessiner des figures, des graphiques
\usepackage{pgfplots}
%\usepackage{adjustbox}% permet de déterminer une taille de fenêtre
%%  FONT
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
\usepackage{tgadventor}% paquet de police de caractère TGadventor
\usepackage{sansmath}%  Copie-colle la police active dans 
%                       \sfdefault (/!\ N'EST PAS UNE POLICE DE CARACTÈRES)
\usepackage{xcolor}
\usetikzlibrary{arrows.meta}

%%%
\tikzset{graphpgf/.style={font={\sansmath\sffamily\Large}, line cap=round, line join=round, >={Latex[length=3mm]}, x=1.0cm, y=1.0cm}}

%%%     Paramètre graphique des graphiques orthonormés pgfplots
\pgfplotsset{/pgfplots/graphxy/.style={
        %%%%%%%%%%  Dimensionnement de l'image  %%%%%%%%%%
        width=15cm,
        height=15cm,
        unit vector ratio=1 1 1,
        %%%%%%%%%%  esthétique des axes  %%%%%%%%%%
        xlabel=$x$,         ylabel=$y$,
        axis lines = middle,
        enlargelimits=false,
        line width=0.4mm,
        every major grid/.append style={black!20, line width=0.35mm,},
        every minor grid/.append style={black!15, line width=0.15mm,},
        every major tick/.append style={line width=0.4 mm, major tick length=7pt, black},
        every minor tick/.append style={line width=0.15mm, minor tick length=4pt, black},
        axis background/.style={fill=white,},
        grid=both,
        axis line style = {shorten >=-12.5pt, shorten <=-12.5pt, -{Latex[length=3mm]}},
        xlabel style={at={(ticklabel* cs:1)},yshift=-3.5pt, anchor=north west, font=\sansmath\sffamily\Large},
        ylabel style={at={(ticklabel* cs:1)},xshift=-3.5pt,, anchor=south east, font=\sansmath\sffamily\Large},
        title style = {font=\sansmath\sffamily\Large, align=center, inner sep=12pt,},
        }
    }
%%%%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[graphpgf,]

\draw[fill=black!50]
    (-1,-1) rectangle (15,12)
;

%%%%%%%%%%%%%%%%%% Data Table %%%%%%%%%%%%%%%%%%
\begin{axis}[%
    graphxy,
    %%%     Axe x
    xmin=-5-0.5, xmax=5+0.5,
    xtick={-15,...,15},
    %minor xtick={-10,...,8},
    %domain=-10:10,
    %%%     Axe x
    ymin=-4-0.5,ymax=4+0.5,
    ytick={-15,...,15},
    %minor ytick={-8,...,8},
    %minor tick num=1,
           ]%
           \draw[] 
            (axis cs:0,0) coordinate node [circle, fill=black, draw=black, scale=.2, label={[inner sep=6pt, xshift=6pt]below:0}] {}
            ;
            \draw[]
            (axis cs:-4,1) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:A}] {}
            (axis cs:-2,3) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:B}] {}
            (axis cs:-1,2) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:C}] {}
            (axis cs:3,3) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:D}] {}
            (axis cs:4,1) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:E}] {}
            (axis cs:1,-1) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:F}] {}
            (axis cs:-3,-3) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:G}] {}
            (axis cs:2,-2) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:H}] {}
            ;
\end{axis}

\end{tikzpicture}
\end{document}

答案1

像这样?

%%%%%%%%%%%%%%%%%% INTRODUCTION %%%%%%%%%%%%%%%%%%
\documentclass[border=10pt]{standalone}
%%%%%%%%%%%%%%%%%% INPUT %%%%%%%%%%%%%%%%%%
%\input{preamble.tex}
%\input{parameters.tex}
%%%%%%%%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%%%%%%
\usepackage{tikz, tkz-euclide}%  permet de dessiner des figures, des graphiques
\usepackage{pgfplots}
%\usepackage{adjustbox}% permet de déterminer une taille de fenêtre
%%  FONT
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
\usepackage{tgadventor}% paquet de police de caractère TGadventor
\usepackage{sansmath}%  Copie-colle la police active dans 
%                       \sfdefault (/!\ N'EST PAS UNE POLICE DE CARACTÈRES)
\usepackage{xcolor}
\usetikzlibrary{arrows.meta,backgrounds}

%%%
\tikzset{graphpgf/.style={font={\sansmath\sffamily\Large},
     line cap=round, line join=round, >={Latex[length=3mm]}, x=1.0cm, y=1.0cm,
     background rectangle/.style={draw,line width=1cm,black!50},
    show background rectangle,inner frame sep=1cm}}

%%%     Paramètre graphique des graphiques orthonormés pgfplots
\pgfplotsset{/pgfplots/graphxy/.style={
        %%%%%%%%%%  Dimensionnement de l'image  %%%%%%%%%%
        width=15cm,
        height=15cm,
        unit vector ratio=1 1 1,
        %%%%%%%%%%  esthétique des axes  %%%%%%%%%%
        xlabel=$x$,         ylabel=$y$,
        axis lines = middle,
        enlargelimits=false,
        line width=0.4mm,
        every major grid/.append style={black!20, line width=0.35mm,},
        every minor grid/.append style={black!15, line width=0.15mm,},
        every major tick/.append style={line width=0.4 mm, major tick length=7pt, black},
        every minor tick/.append style={line width=0.15mm, minor tick length=4pt, black},
        %axis background/.style={fill=white,},
        grid=both,
        axis line style = {shorten >=-12.5pt, shorten <=-12.5pt, -{Latex[length=3mm]}},
        xlabel style={at={(ticklabel* cs:1)},yshift=-3.5pt, anchor=north west, font=\sansmath\sffamily\Large},
        ylabel style={at={(ticklabel* cs:1)},xshift=-3.5pt,, anchor=south east, font=\sansmath\sffamily\Large},
        title style = {font=\sansmath\sffamily\Large, align=center, inner sep=12pt,},
        }
    }
%%%%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[graphpgf]


%%%%%%%%%%%%%%%%%% Data Table %%%%%%%%%%%%%%%%%%
\begin{axis}[%
    graphxy,
    %%%     Axe x
    xmin=-5-0.5, xmax=5+0.5,
    xtick={-15,...,15},
    %minor xtick={-10,...,8},
    %domain=-10:10,
    %%%     Axe x
    ymin=-4-0.5,ymax=4+0.5,
    ytick={-15,...,15},
    %minor ytick={-8,...,8},
    %minor tick num=1,
           ]%
           \draw[] 
            (axis cs:0,0) coordinate node [circle, fill=black, draw=black, scale=.2, label={[inner sep=6pt, xshift=6pt]below:0}] {}
            ;
            \draw[]
            (axis cs:-4,1) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:A}] {}
            (axis cs:-2,3) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:B}] {}
            (axis cs:-1,2) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:C}] {}
            (axis cs:3,3) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:D}] {}
            (axis cs:4,1) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:E}] {}
            (axis cs:1,-1) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:F}] {}
            (axis cs:-3,-3) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:G}] {}
            (axis cs:2,-2) coordinate node [circle, fill=black, scale=.5, label={[inner sep=6pt, xshift=6pt]above:H}] {}
            ;
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您可以通过缩放和移动轴背景样式来修改轴背景样式,如下所示:

axis background/.style={fill=yellow,scale=1.2,shift={(-1cm,-1cm)}}

在此处输入图片描述

相关内容