我之前问过这个问题,但有人说需要澄清。抱歉疏忽了,
我想绘制一个堆叠区域。但是,当尝试使用辅助 y 轴时,“yticklabel”的位置不正确。例如,数字 10、20、30 稍微“向下移动”(例如,1990 年的第一个蓝色块是 8.3,但在右侧定义 y 轴时,它似乎大于 10)。如果我使用左侧的 y 轴,则不会发生这种情况。
我将非常感激您的任何评论。
我的母亲:
\documentclass[letterpaper,12.0pt]{report}
\usepackage{pgfplots}
\begin{document}
\centering
\begin{tikzpicture}
\begin{axis}[
width=16.0cm,
height=0.45\textheight,
area style,
enlarge x limits=false,
stack plots=y,
grid=none,
ymin=0,
ymax=35,
xmin=1989,
xmax=2023,
symbolic x coords={1989,
1990, 91, 92, 93, 94, 95, 96, 97, 98, 99,
00, 01, 02, 03, 04, 05, 06, 07, 08, 09,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 2022, 2023},
xtick=data,
xtick={1990,95,00,05,10,15,2022},
xticklabels={1990,95,00,05,10,15,2022},
nodes near coords={},
nodes near coords align={vertical},
xticklabel style={font=\footnotesize, black},
axis x line*=bottom,
xtick style={draw=none},
axis y line*=right,
ylabel near ticks,
yticklabel pos=right,
y axis line style={draw opacity=0},
yticklabels={},
ytick={10,20,30},
extra y ticks={10,20,30},
]
% Concentrates
\addplot [draw=blue!75!white, fill=blue!75!white, opacity=0.70] coordinates
{(1990, 8.343) (91, 8.674) (92, 8.722) (93, 8.811) (94, 8.705) (95, 8.996) (96, 9.628) (97, 9.766) (98, 10.226) (99, 10.455) (00, 10.878) (01, 11.039) (02, 10.835) (03, 10.977) (04, 11.889) (05, 12.233) (06, 12.161) (07, 12.523) (08, 12.450) (09, 12.677) (10, 12.662) (11, 12.501) (12, 13.034) (13, 14.381) (14, 14.514) (15, 15.238) (16, 16.484) (17, 16.280) (18, 16.641) (19, 16.528) (20, 16.585) (21, 17.247) (2022, 17.618)} \closedcycle;
% SX/EW
\addplot [draw=red!75!white, fill=red!75!white, opacity=0.70] coordinates
{(1990, 0.884) (91, 0.699) (92, 0.776) (93, 0.761) (94, 0.835) (95, 1.074) (96, 1.456) (97, 1.748) (98, 2.001) (99, 2.312) (00, 2.321) (01, 2.597) (02, 2.652) (03, 2.722) (04, 2.706) (05, 2.694) (06, 2.823) (07, 2.985) (08, 3.082) (09, 3.264) (10, 3.324) (11, 3.459) (12, 3.644) (13, 3.791) (14, 3.906) (15, 3.914) (16, 3.912) (17, 3.785) (18, 3.957) (19, 4.142) (20, 4.161) (21, 4.013) (2022, 4.303)}
\closedcycle;
% Direct melt
\addplot [draw=yellow!60!white, fill=yellow!60!white, opacity=0.70] coordinates
{(1990, 3.547) (91, 3.557) (92, 3.740) (93, 3.876) (94, 4.422) (95, 4.892) (96, 4.866) (97, 5.082) (98, 4.828) (99, 4.650) (00, 5.269) (01, 4.766) (02, 5.009) (03, 4.803) (04, 5.117) (05, 5.188) (06, 5.470) (07, 5.662) (08, 5.412) (09, 4.683) (10, 5.104) (11, 5.327) (12, 5.321) (13, 5.434) (14, 5.674) (15, 5.629) (16, 5.715) (17, 6.005) (18, 6.251) (19, 6.136) (20, 5.973) (21, 6.332) (2022, 6.341)}
\closedcycle;
% Secondary refined
\addplot [draw=black!30!white, fill=black!30!white, opacity=0.70] coordinates
{(1990, 1.904) (91, 1.863) (92, 1.827) (93, 1.882) (94, 1.805) (95, 2.099) (96, 1.997) (97, 2.130) (98, 2.112) (99, 2.139) (00, 2.097) (01, 1.892) (02, 1.898) (03, 1.786) (04, 2.069) (05, 2.161) (06, 2.613) (07, 2.739) (08, 2.825) (09, 2.847) (10, 3.236) (11, 3.468) (12, 3.596) (13, 3.803) (14, 3.915) (15, 3.945) (16, 3.866) (17, 4.063) (18, 4.035) (19, 4.007) (20, 3.843) (21, 4.149) (2022, 4.153)}
\closedcycle;
\end{axis}
\node[black, font=\footnotesize, anchor=south] at (14.5, 9.1) {[Mt]};
\end{tikzpicture}
\end{document}