我需要函数 $(1/x)^(1/y)$ 的曲面,其范围是 x:10^1 - 10^8 和 y:10^1 - 10^5。x 轴和 y 轴最好采用对数刻度。我尝试了不同的方法,但似乎都不起作用。(请参阅下面我尝试的方法)。
\documentclass[border= 5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
scale = 1,
xlabel = {x},
xmin = 10, xmax = 100000000,
ylabel = {y},
ymin = 10, ymax = 100000,
zlabel={z},
zmin = 0, zmax = 1,
view={45}{10},
]
\addplot3[
surf,
samples=50,
domain=10:100000000,
domain y=10:100000,
]
{(1/x)^(1/y)};
%other approach
%\addplot3 [surf] gnuplot [raw gnuplot]{
% set dgrid3d 50,50 spline;
% splot "data.txt"; %
% };
\end{axis}
\end{tikzpicture}
\end{document}
答案1
PGFPlots 沿线性轴对域进行均匀采样,但不沿对数轴采样。要解决这个问题,您可以设置
domain=1:8,
domain y=1:5
然后使用指定图
\addplot3 [surf] (10^x, 10^y, {(1/(10^x))^(1/(10^y))});;
\documentclass[border= 5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
scale = 1,
xlabel = {x},
xmin = 10, xmax = 1e8,
ylabel = {y},
ymin = 10, ymax = 1e5,
zlabel={z},
zmin = 0, zmax = 1,
xmode=log, ymode=log
]
\addplot3[
surf,
samples=30,
domain=1:8,
domain y=1:5,
]
(10^x, 10^y, {(1/(10^x))^(1/(10^y))});
\end{axis}
\end{tikzpicture}
\end{document}