彩条 - 冲浪图

彩条 - 冲浪图

我有一个如下所示的冲浪图。在此处输入图片描述但是,颜色条上的标记是以 0.05 为步长的。相反,我希望标记以 0.25 为步长。我该怎么做呢?以下是生成上面显示的冲浪图的代码。

\begin{tikzpicture}[scale=0.15]
\pgfplotsset{compat=newest}
\tikzstyle{every node}=[font=\Huge]
every mark/.append style={rotate=90}.
\begin{axis}[
colorbar,
view={60}{30},
smooth,
mark size = 1.5,
xmin=16, xmax=24,
ymin=1650, ymax=1675,
zmin=0.25, zmax=2.25,
xtick = {16,18,20,22},
ytick = {1650,1655,1660,1665,1670,1675},
ztick = {0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25},
xlabel= $a$,
ylabel= $b$,
zlabel= Relative error,
xlabel style = {sloped like x axis},
ylabel style = {sloped like y axis},
]
\addplot3[surf,mesh/rows=5,shader=interp] coordinates {
(16,1650,1.6148) (18,1650,1.6283) (20,1650,1.6421) (22,1650,1.6449) (24,1650,1.6579)
(16,1655,1.5114) (18,1655,1.5058) (20,1655,1.4948) (22,1655,1.4738) (24,1655,1.4474)
(16,1660,1.2262) (18,1660,1.2302) (20,1660,1.2280) (22,1660,1.2320) (24,1660,1.2283)
(16,1665,0.3534) (18,1665,0.3103) (20,1665,0.3159) (22,1665,0.3312) (24,1665,0.3621)
(16,1675,2.0557) (18,1675,1.0734) (20,1675,1.0279) (22,1675,0.9771) (24,1675,0.9127)
};
\end{axis}
\end{tikzpicture}

答案1

您可以使用colorbar style={ ytick={0.50, 0.75, ..., 2.00} }来选择颜色条的刻度标签:

在此处输入图片描述

笔记:

  • 我不确定我的安装是否有问题,但我必须删除 Mac 上的您的scale\tikzstyle设置才能获得不错的图像。在我的 PC 版本上,我不需要这样做 - 但根据我以前遇到的问题,我认为 Mac 安装没有问题,而 PC 安装已损坏> 但 PC 安装产生的结果与您的相同,所以我不知道。

代码:

\documentclass{article}
\usepackage{pgfplots}

\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
%\tikzstyle{every node}=[font=\Huge]
%every mark/.append style={rotate=90}.
\begin{axis}[
colorbar, colorbar style={ ytick={0.50, 0.75, ..., 2.00} },
view={60}{30},
smooth,
mark size = 1.5,
xmin=16, xmax=24,
ymin=1650, ymax=1675,
zmin=0.25, zmax=2.25,
xtick = {16,18,20,22},
ytick = {1650,1655,1660,1665,1670,1675},
ztick = {0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25},
xlabel= $a$,
ylabel= $b$,
zlabel= Relative error,
xlabel style = {sloped like x axis},
ylabel style = {sloped like y axis},
]
\addplot3[surf,mesh/rows=5,shader=interp] coordinates {
(16,1650,1.6148) (18,1650,1.6283) (20,1650,1.6421) (22,1650,1.6449) (24,1650,1.6579)
(16,1655,1.5114) (18,1655,1.5058) (20,1655,1.4948) (22,1655,1.4738) (24,1655,1.4474)
(16,1660,1.2262) (18,1660,1.2302) (20,1660,1.2280) (22,1660,1.2320) (24,1660,1.2283)
(16,1665,0.3534) (18,1665,0.3103) (20,1665,0.3159) (22,1665,0.3312) (24,1665,0.3621)
(16,1675,2.0557) (18,1675,1.0734) (20,1675,1.0279) (22,1675,0.9771) (24,1675,0.9127)
};
\end{axis}
\end{tikzpicture}
\end{document}

相关内容