그래프의 진드기에 대한 질문

그래프의 진드기에 대한 질문

배경에 그리드가 있는 그래프를 만들려고 합니다. 표준 창 크기가 되기를 원하지만 x축과 y축 모두에서 -10과 10 옆에 있는 숫자만 원합니다. 이 코드를 사용하고 있습니다

\begin{tikzpicture}
\begin{axis}[
  axis lines=middle,
  grid=major,
  xmin=-10,
  xmax=10,
  ymin=-10,
  ymax=10,
  xlabel=$x$,
  ylabel=$y$,
  xtick={-10,...,10},
  ytick={-10,...,10},
  tick style={very thick},
  legend style={
  at={(rel axis cs:0,1)},
  anchor=north west,draw=none,inner sep=0pt,fill=gray!10}
]
\addplot[domain=-3:3,blue,thick,samples=100,<->] {x^2};
\addplot[holdot] coordinates{(0,0)(4,4)(6,-5)};
\addplot[soldot] coordinates{(4,16)(6,6)(10,-5)};
%%\addlegendentry{$y=x^2$}
%%\addplot[domain=0:4,blue,] {x*x};
\addplot[domain=4:6,blue,] {x};
\addplot[domain=6:10,blue] {-5};
\end{axis}
\end{tikzpicture}

변경하면 xtick={-10,...,10},그리드도 사라지고 그렇지 않은 다른 모든 틱 -10도 또는10

체크 표시는 있지만 숫자는 표시되지 않도록 하려면 어떻게 해야 합니까?

업데이트됨: 원래 문제를 해결한 업데이트 버전이지만 지금은 x축, y축 라벨의 적절한 배치를 찾으려고 노력 중입니다.

\begin{tikzpicture}
\centering
\begin{axis}[
  axis lines=middle,
  grid=major,
  xmin=-10,
  xmax=10,
  ymin=-10,
  ymax=10,
  xlabel style ={at={(1,0.5)},above right},
  ylabel style ={at={(0.5,1)},above right},
  xtick={-10,...,10},
  xticklabels={},    %% no x tick labels
  ytick={-10,...,10},
  yticklabels={},    %% no y tick labels
  extra x ticks={-10,10},
  extra x tick labels={-10,10},
  extra y ticks={-10,10},
  extra y tick labels={-10,10},
  tick style={very thick},
  legend style={
  at={(rel axis cs:0,1)},
  anchor=north west,draw=none,inner sep=0pt,fill=gray!10}
]
\addplot[domain=-10:10,blue,thick,samples=1000,->] {sqrt (x+4)};
%%\addplot[holdot] coordinates{(0,0)(4,4)(6,-5)};
\addplot[soldot] coordinates{(0,2)(5,3)};
%%\addlegendentry{$y=x^2$}
%%\addplot[domain=0:4,blue,] {x*x};
%%\addplot[domain=4:6,blue,] {x};
%%\addplot[domain=6:10,blue] {-5};
\end{axis}
\end{tikzpicture}

답변1

당신이 사용할 수있는

  xticklabels={},      %% no x tick labels
  yticklabels={},      %% no y tick labels
  extra x ticks={-10,10},
  extra x tick labels={-10,10},
  extra y ticks={-10,10},
  extra y tick labels={-10,10},

암호:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
  \begin{tikzpicture}
\begin{axis}[
  axis lines=middle,
  grid=major,
  xmin=-10,
  xmax=10,
  ymin=-10,
  ymax=10,
  xlabel=$x$,
  ylabel=$y$,
  xtick={-10,...,10},
  xticklabels={},    %% no x tick labels
  ytick={-10,...,10},
  yticklabels={},    %% no y tick labels
  extra x ticks={-10,10},
  extra x tick labels={-10,10},
  extra y ticks={-10,10},
  extra y tick labels={-10,10},
  tick style={very thick},
  legend style={
  at={(rel axis cs:0,1)},
  anchor=north west,draw=none,inner sep=0pt,fill=gray!10}
]
\addplot[domain=-3:3,blue,thick,samples=100,<->] {x^2};
\addplot coordinates{(0,0)(4,4)(6,-5)};
\addplot coordinates{(4,16)(6,6)(10,-5)};
%%\addlegendentry{$y=x^2$}
%%\addplot[domain=0:4,blue,] {x*x};
\addplot[domain=4:6,blue,] {x};
\addplot[domain=6:10,blue] {-5};
\end{axis}
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

xlabel style ={at={(1,0.5)},above right},
ylabel style ={at={(0.5,1)},above right},

얻을 축 옵션에서

여기에 이미지 설명을 입력하세요

xlabel수정된 질문의 경우 및 를 지정해야 합니다 ylabel.

  xlabel=$x$,
  ylabel=$y$,
  xlabel style ={at={(1,0.5)},above right},
  ylabel style ={at={(0.5,1)},above right},

혼란을 없애기 위해 코드를 완성하세요.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\centering
\begin{axis}[
  axis lines=middle,
  grid=major,
  xmin=-10,
  xmax=10,
  ymin=-10,
  ymax=10,
  xlabel=$x$,
  ylabel=$y$,
  xlabel style ={at={(1,0.5)},above right},
  ylabel style ={at={(0.5,1)},above right},
  xtick={-10,...,10},
  xticklabels={},    %% no x tick labels
  ytick={-10,...,10},
  yticklabels={},    %% no y tick labels
  extra x ticks={-10,10},
  extra x tick labels={-10,10},
  extra y ticks={-10,10},
  extra y tick labels={-10,10},
  tick style={very thick},
  legend style={
  at={(rel axis cs:0,1)},
  anchor=north west,draw=none,inner sep=0pt,fill=gray!10},clip=false
]
\addplot[domain=-10:10,blue,thick,samples=1000,->] {sqrt (x+4)};
%%\addplot[holdot] coordinates{(0,0)(4,4)(6,-5)};
\addplot coordinates{(0,2)(5,3)};
%%\addlegendentry{$y=x^2$}
%%\addplot[domain=0:4,blue,] {x*x};
%%\addplot[domain=4:6,blue,] {x};
%%\addplot[domain=6:10,blue] {-5};
\end{axis}
\end{tikzpicture}

\end{document}

관련 정보