
下の図では、図のように x 軸に 2 つのラベルを表示する必要があります。問題は、図の「HERE」の場所に下側の温度ラベルを表示する必要があることです。 を使用してabove
テキストをノード位置の上に配置できますが、 を使用すると軸ラベルが表示されません。または をノード位置からbelow
省略すると、テキストの上半分が軸線の上に表示されます。above
below
私はついていきます答えこの投稿から、しかし、重要な違いが 1 つあります (私が知る限り)。デフォルトの軸ラベルをグラフの上に設定し、セカンダリ ラベルをグラフの下に設定しました。
これは一連のグラフの 1 つです。生徒の理解を助けるために、一度に 1 つの項目ずつグラフを「作成」しています。理解を助けるために、一時的に x 軸ラベルを追加したいと思います。次のグラフでは、2 番目の変数 (シード サイズ) に対して同じことを行います。残りの図では、グラフの上部にのみラベルが付きます。
\documentclass[border=10pt]{article}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{
% Set `compat level to 1.11 or higher so you don't need to
% prefix every tikz coordinate with `axis cs:'
compat=1.14,
3dbaseplot/.style={
width = 10cm,
view = {45}{65},
axis on top,
enlargelimits = false,
domain = 1:4,
y domain = 1:4,
no markers,
samples = 30,
xlabel = {Temperature},
ylabel = {Seed Size},
zlabel = {Relative\\Abundance},
xlabel style = {sloped, at={(rel axis cs:0.5,1,1)}, above, sloped like x axis},
ylabel style = {sloped, at={(rel axis cs:0,0.5,1)}, above, sloped like y axis},
zlabel style = {rotate=-90, align=right},
ticks = none,
smooth,
},
/pgf/declare function = {
normal(\m,\s)=1/(2*\s*sqrt(pi))*exp(-(x-\m)^2/(2*\s^2));
},
/pgf/declare function = {
bivar(\ma,\sa,\mb,\sb)=
1/(2*pi*\sa*\sb) * exp(-((x-\ma)^2/\sa^2 + (y-\mb)^2/\sb^2))/2;
}
}
\pgfmathsetmacro{\factor}{3}
\newcommand*\myaddplotX[4]{
\addplot3+ [name path=#1,domain=#2-\factor*#3:#2+\factor*#3, color=#4] (x,4,{normal(#2,#3)});
}
\newcommand*\myaddplotY[4]{
\addplot3+ [name path=#1,domain=#2-\factor*#3:#2+\factor*#3, color=#4] (1,x,{normal(#2,#3)});
}
\begin{document}
\begin{tikzpicture}[
declare function = {orMuX=2.0;},
declare function = {orMuY=3.2;},
declare function = {blMuX=2.5;},
declare function = {blMuY=2.7;},
declare function = {sX=0.25;},
declare function = {sY=0.15;},
]
\begin{axis}[
3dbaseplot,
colormap/OrRd,
set layers,
ylabel={},
samples=30,
]
\myaddplotX{B}{blMuX}{sX}{white}
\myaddplotY{C}{blMuY}{sY}{white}
\myaddplotY{D}{orMuY}{sY}{white}
\myaddplotX{A}{orMuX}{sX}{orange}
\draw [dashed] (2.0-\factor*sX, 1) -- (2.0-\factor*sX, 4);
\draw [dashed] (2.0+\factor*sX, 1) -- (2.0+\factor*sX, 4);
%% This places the text above the axis. I don't want this one.
\node at (xticklabel cs:0.5) [above, sloped like x axis] {Temperature};
%% THIS DOES NOT APPEAR.This is the one I want.
\node at (xticklabel cs:0.5) [below, sloped like x axis] {Temperature};
\end{axis}
\end{tikzpicture}
\end{document}
答え1
ただの楽しみのために投げ込んでみましたxslant
。
\documentclass[border=10pt]{article}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{
% Set `compat level to 1.11 or higher so you don't need to
% prefix every tikz coordinate with `axis cs:'
compat=1.14,
3dbaseplot/.style={
width = 10cm,
view = {45}{65},
axis on top,
enlargelimits = false,
domain = 1:4,
y domain = 1:4,
no markers,
samples = 30,
xlabel = {Temperature},
ylabel = {Seed Size},
zlabel = {Relative\\Abundance},
xlabel style = {sloped, at={(rel axis cs:0.5,1,1)}, above, sloped like x axis},
ylabel style = {sloped, at={(rel axis cs:0,0.5,1)}, above, sloped like y axis},
zlabel style = {rotate=-90, align=right},
ticks = none,
smooth,
},
/pgf/declare function = {
normal(\m,\s)=1/(2*\s*sqrt(pi))*exp(-(x-\m)^2/(2*\s^2));
},
/pgf/declare function = {
bivar(\ma,\sa,\mb,\sb)=
1/(2*pi*\sa*\sb) * exp(-((x-\ma)^2/\sa^2 + (y-\mb)^2/\sb^2))/2;
}
}
\pgfmathsetmacro{\factor}{3}
\newcommand*\myaddplotX[4]{
\addplot3+ [name path=#1,domain=#2-\factor*#3:#2+\factor*#3, color=#4] (x,4,{normal(#2,#3)});
}
\newcommand*\myaddplotY[4]{
\addplot3+ [name path=#1,domain=#2-\factor*#3:#2+\factor*#3, color=#4] (1,x,{normal(#2,#3)});
}
\begin{document}
\begin{tikzpicture}[
declare function = {orMuX=2.0;},
declare function = {orMuY=3.2;},
declare function = {blMuX=2.5;},
declare function = {blMuY=2.7;},
declare function = {sX=0.25;},
declare function = {sY=0.15;},
]
\begin{axis}[
3dbaseplot,
colormap/OrRd,
set layers,
ylabel={},
samples=30,
]
\myaddplotX{B}{blMuX}{sX}{white}
\myaddplotY{C}{blMuY}{sY}{white}
\myaddplotY{D}{orMuY}{sY}{white}
\myaddplotX{A}{orMuX}{sX}{orange}
\draw [dashed] (2.0-\factor*sX, 1) -- (2.0-\factor*sX, 4);
\draw [dashed] (2.0+\factor*sX, 1) -- (2.0+\factor*sX, 4);
\coordinate (A1) at (rel axis cs: 0,0,0);
\coordinate (A2) at (rel axis cs: 1,0,0);
\end{axis}
\path (A1) -- (A2) node[midway, above, sloped, xslant=.5] {Temperature};
\path (A1) -- (A2) node[midway, below, sloped, xslant=.5] {Temperature};
\end{tikzpicture}
\end{document}