
Я пытаюсь построить допустимый набор задачи максимизации. Одно из ограничений неполное, так как оно должно простираться до оси x.
Кроме того, я полагаю, что center
окружающая среда заставляет весь рисунок и подпись центрироваться относительно страницы, но я ожидал, что рисунок также будет центрироваться относительно подписи.
MWE — это
\documentclass[a4paper]{article}
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{center}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
ticks=none,
axis x line=bottom,
axis y line=left,
xmin=0,xmax=1.2,
ymin=0,ymax=1.3]
\addplot[
domain = 0:sqrt(33/56),
samples =200,
smooth,
blue,
thick
] {sqrt((33/8-7*x^2)/3)};
\end{axis}
\end{tikzpicture}
\caption{This is text just to show that the figure is not centered with respect to the caption.}
\end{figure}
\end{center}
\end{document}
решение1
Расширяя ответ @RaffaeleSantoro:
Использование samples = 800
помогает.
Кроме того, не помещайте figure
внутрь center
окружения, а используйте \centering
внутри, figure
например, так:
\documentclass[a4paper]{article}
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
ticks=none,
axis x line=bottom,
axis y line=left,
xmin=0,xmax=1.2,
ymin=0,ymax=1.3]
\addplot[
domain = 0:sqrt(33/56),
samples =800,
smooth,
blue,
thick
] {sqrt((33/8-7*x^2)/3)};
\end{axis}
\end{tikzpicture}
\caption{This is text just to show that the figure is not centered with respect to the caption.}
\end{figure}
\end{document}
решение2
Это не потому, что последняя точка не «достигнута». Функция не определена справа от sqrt(33/56)
и с конечной точностью компьютеров невозможно оценить функцию в sqrt(33/56)
любой из них. - Точка отбрасывается - посмотрите на журнал компиляции. Одна из возможностей - значительно увеличить количество выборок, так что предпоследняя точка даст приемлемый результат. Другой способ - определить точку отдельно с помощью Вот так y filter
:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ticks=none,
axis x line=bottom,
axis y line=left,
xmin=0,xmax=1.2,
ymin=0,ymax=1.3]
\addplot[
domain=0:sqrt(33/56),
samples=200,
smooth,
blue, thick,
y filter/.expression={x==sqrt(33/56)?0:y},
] {sqrt((33/8-7*x^2)/3)};
\end{axis}
\end{tikzpicture}
\end{document}