![PGFPlots ではプロットされた方程式が x=5 で停止します](https://rvso.com/image/476244/PGFPlots%20%E3%81%A7%E3%81%AF%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%81%95%E3%82%8C%E3%81%9F%E6%96%B9%E7%A8%8B%E5%BC%8F%E3%81%8C%20x%3D5%20%E3%81%A7%E5%81%9C%E6%AD%A2%E3%81%97%E3%81%BE%E3%81%99.png)
PGFPlots を使用して 2 つの方程式をプロットしようとしています。それらは-(x-7)^2+12
とです(x-6)^2-2
。ただし、結果のグラフは x=5 を超えて描画されません。プロットを構成するために使用しているコードを確認しましたが、問題の原因は何も見当たりません。
最小限の動作例:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = middle,
xmin = 0, xmax = 10,
xtick = {0,2,...,10},
extra y ticks = 0,
ymin = -5, ymax = 15,
ytick = {-5,0,...,15},
samples = 100,
]
\addplot[color=red]{-(x-7)^2+12};
\addplot[color=blue]{(x-6)^2-2};
\end{axis}
\end{tikzpicture}
\end{document}
答え1
PGFPlotsdomain={-5:5}
デフォルトごとのセット数これによりプロットは-5 ≤バツ≤ 5. ただし、これは簡単に変更できます。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = middle,
xmin = 0, xmax = 10,
xtick = {0,2,...,10},
extra y ticks = 0,
ymin = -5, ymax = 15,
ytick = {-5,0,...,15},
samples = 100,
domain = {0:10}
]
\addplot[color=red]{-(x-7)^2+12};
\addplot[color=blue]{(x-6)^2-2};
\end{axis}
\end{tikzpicture}
\end{document}
(このオプションはコマンドでも使用できます\addplot
。)