y 오른쪽 축 사용 - tikz

y 오른쪽 축 사용 - tikz

전에도 물어봤는데 누군가는 설명이 필요하다고 하더군요. 감독해서 죄송합니다.

누적된 영역을 플롯하고 싶습니다. 그러나 보조 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}

답변1

아마도 시각적 효과일 뿐입니다.

  • 그리드를 켜세요. 언급하신 내용은 괜찮습니다.
  • 마지막 y 데이터를 모두 추가해도 괜찮습니다.

따라서 여기서 해결해야 할 것은 데이터를 표현하는 방법 외에는 없습니다.

여기에 이미지 설명을 입력하세요

관련 정보