我遇到了 tikz 图片跳跃的问题。当我添加填充时,图片会跳跃,如下例所示。有趣的是,这是我在 Mac 上遇到的问题,但在 Ubuntu 电脑上没有遇到。
\documentclass[10pt, aspectratio=169]{beamer}
%%Theme stuffx
\usetheme{Warsaw}
\usepackage{appendixnumberbeamer}
\usepackage{booktabs}
\usepackage{pgfplots}
\usepackage{subcaption}
\usepackage{mathtools}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{frame}{AAA}
\def \myscale {0.9}
\centering
\pgfplotsset{every axis/.append style={
axis line style={->}, % arrows on the axis
xlabel={}, % default put x on x-axis
ylabel={}, % default put y on y-axis
ticks=none,
grid=none,
}}
\centering
\tikzset{>=stealth}
\begin{tikzpicture}[scale=\myscale] %%def \myscale
\begin{axis}[
axis equal,
axis x line* = center,
axis y line* = center,
xmin=-0.05,xmax=1.05,
ymin=-0.05 ,ymax=1.05,
scale=1.5,
transform shape
]
%% parameters
\def \wtilde {0.25} %% phi(wtilde)=0
\def \concav {2} %% phi has a power 1/concav
\def \phimax {0.63} %% phi(1)=phimax
\plot[name path=f1,thick, color = black, dotted, samples=100, domain=\wtilde:1] {\phimax * ( (x-\wtilde)/(1- \wtilde) )^(1/\concav)};
\plot[name path=X1,thick,opacity=0,samples=2,domain=\wtilde:1] {0};
\plot[name path=X2,thick,opacity=0,samples=2,domain=0:\phimax] {1};
\end{axis}
\end{tikzpicture}
\end{frame}
\begin{frame}{AAA}
\def \myscale {0.9}
\centering
\pgfplotsset{every axis/.append style={
axis line style={->}, % arrows on the axis
xlabel={}, % default put x on x-axis
ylabel={}, % default put y on y-axis
ticks=none,
grid=none,
}}
\centering
\tikzset{>=stealth}
\begin{tikzpicture}[scale=\myscale] %%def \myscale
\begin{axis}[
axis equal,
axis x line* = center,
axis y line* = center,
xmin=-0.05,xmax=1.05,
ymin=-0.05 ,ymax=1.05,
scale=1.5,
transform shape
]
%% parameters
\def \wtilde {0.25} %% phi(wtilde)=0
\def \concav {2} %% phi has a power 1/concav
\def \phimax {0.63} %% phi(1)=phimax
\plot[name path=f1,thick, color = black, dotted, samples=100, domain=\wtilde:1] {\phimax * ( (x-\wtilde)/(1- \wtilde) )^(1/\concav)};
\plot[name path=X1,thick,opacity=0,samples=2,domain=\wtilde:1] {0};
\plot[name path=X2,thick,opacity=0,samples=2,domain=0:\phimax] {1};
% %
\addplot fill between[
of = f1 and X1,
soft clip={domain=0:1},
every even segment/.style = {black,opacity=1}
];
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}
答案1
我无法重现您的问题。在您的文档中,两个框架中的设置可能不一致。为了避免可能出现的差异,我建议为两个图像定义通用轴选项:
\documentclass[10pt, aspectratio=169]{beamer}
% Theme stuff
\usetheme{Warsaw}
% general packages
\usepackage{appendixnumberbeamer}
\usepackage{booktabs}
\usepackage{subcaption}
\usepackage{mathtools}
% for drawing diagrams
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=1.18,
PLOT/.style={ % common definition of diaghram styles
height=\textheight,
axis lines = center,
axis line style={-Stealth}, % arrows on the axis
grid=none,
ticks=none,
axis equal,
xmin=-0.05,xmax=1.05,
ymin=-0.05 ,ymax=1.05,
xlabel={}, % default put x on x-axis
ylabel={}, % default put y on y-axis
every axis plot post/.append style={thick}
}}
\begin{document}
\begin{frame}{AAA}
\centering
\begin{tikzpicture}
\begin{axis}[PLOT]
%% parameters
\def \wtilde {0.25} % phi(wtilde)=0
\def \concav {2} % phi has a power 1/concav
\def \phimax {0.63} % phi(1)=phimax
% diagram
\plot[thick, dotted, samples=100, domain=\wtilde:1]
{\phimax*((x-\wtilde)/(1-\wtilde))^(1/\concav)};
\end{axis}
\end{tikzpicture}
\end{frame}
\begin{frame}{BBB}
\centering
\begin{tikzpicture}
\begin{axis}[PLOT]
%% parameters
\def \wtilde {0.25} % phi(wtilde)=0
\def \concav {2} % phi has a power 1/concav
\def \phimax {0.63} % phi(1)=phimax
\plot[name path=f1,dotted, samples=100, domain=\wtilde:1] {\phimax*((x-\wtilde)/(1- \wtilde))^(1/\concav)};
\plot[name path=X1, opacity=0,samples=2,domain=\wtilde:1] {0};
% fill
\addplot fill between[of=f1 and X1,
soft clip={domain=0:1},
every even segment/.style = {black,opacity=1}
];
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}