
누적 영역 플롯에는 세 가지 문제가 있습니다.
1: 프레젠테이션에 맞게 플롯의 폭을 더 넓히고 싶습니다. 하지만 x 방향으로 크기를 조정하면 글꼴(레이블)도 크기 조절됩니다. 그것을 피하는 방법?
2: 진드기 라벨을 얻으려고 시도한 모든 것이 \sffamily
작동하지 않았습니다. 아마도 올바른 스위치를 찾지 못했을 것입니다. 어떻게 해야 합니까?
3: 을(를) 변경하고 싶습니다 xlabels
. 플롯은 2014로 시작해야 하지만 레이블은 2015로 시작해야 합니다. 레이블이 없는 눈금에는 |가 있어야 합니다. 나는 내가 원하는 것을 설명하려고 노력합니다 xlabels
.
__________________________________________
| | | | | | | | | | |
0 2015 2017 2019 2021 2023 2025
이것이 내가 지금까지 시도한 것입니다:
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\usepackage[ngerman]{babel}
\pgfplotstableread[col sep=comma,header=true]{
Year,pid,pack,diff
2014,4.5,4.5,0
2015,3.1,4,0.9
2016,4.5,5.8,1.3
2017,3.1,4.9,1.8
2018,2.8,5.2,2.4
2019,2.3,3.9,1.6
2020,2,3.9,1.9
2021,2.1,3.9,1.8
2022,2.1,5.5,3.4
2023,0,3.95,3.95
2024,0,4,4
2025,0,3.95,3.95
}\table
\pgfplotsset{
/pgfplots/area cycle list/.style={/pgfplots/cycle list={%
{red,fill=red,mark=none},
{blue,fill=blue,mark=none},
}
},
every axis label = {font=\sffamily},
every tick label/.append style={font=\sffamily},
}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
\begin{axis}[
every axis label={font=\sffamily},
legend style = {font=\sffamily},
label style = {font=\sffamily},
tick style = {font=\sffamily},
area style,
stack plots=y,
enlarge x limits=false,
enlarge y limits=upper,
x tick label style={/pgf/number format/1000 sep=},
ylabel=y, y label style={at={(0.05,1)}},%
xlabel=t, x label style={at={(1,0.0)}},%
]
%\pgftransformxscale{1.5}%scales in xdirection but stretches also the font
\addplot table [x=Year, y=pid, fill=green] {\table} \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}
답변1
- 질문은 ~이야어떻게플롯의 크기를 조정합니다.
width
및 명령을 사용하여 축의 크기를 직접 조정하면height
글꼴 크기가 변경되지 않습니다. - 이것은 매우 일반적인 질문과 답변입니다.여기예를 들어. 즉, "일반" 글꼴만 변경하고 "수학" 글꼴은 변경하지 않았습니다. 숫자
tick
는 수학 모드에서 인쇄되므로 기본 수학 글꼴이 제공됩니다. - 여기서는 키를 사용하여 "직접" 라벨을 지정
xtick
하고 표시하려는 값을 제공할 수 있습니다. 코드에서 볼 수 있듯이 "영리한" 버전을 사용할 수도 있습니다. 키를 사용하면minor x tick num
마이너 틱 수를 제공할 수 있습니다.
\documentclass{standalone}
\usepackage[ngerman]{babel}
\usepackage[eulergreek]{sansmath}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\pgfplotstableread[col sep=comma,header=true]{
Year,pid,pack,diff
2014,4.5,4.5,0
2015,3.1,4,0.9
2016,4.5,5.8,1.3
2017,3.1,4.9,1.8
2018,2.8,5.2,2.4
2019,2.3,3.9,1.6
2020,2,3.9,1.9
2021,2.1,3.9,1.8
2022,2.1,5.5,3.4
2023,0,3.95,3.95
2024,0,4,4
2025,0,3.95,3.95
}\table
\pgfplotsset{
/pgfplots/area cycle list/.style={
/pgfplots/cycle list={%
{red,fill=red,mark=none},
{blue,fill=blue,mark=none},
},
},
}
\begin{document}
\begin{tikzpicture}[
font=\sffamily\sansmath,
]
\begin{axis}[
area style,
stack plots=y,
enlarge x limits=false,
enlarge y limits=upper,
x tick label style={/pgf/number format/1000 sep=},
ylabel=y, y label style={at={(0.05,1)}},%
xlabel=t, x label style={at={(1,0.0)}},%
% -------------------------------------------------
% set `xtick's
xtick={2015,2017,...,2025},
% show in between major xticks 1 minor tick
minor x tick num=1,
% change width of the plot
width=10cm,
% and maintain (original) height
% (or also change me, if needed)
height=\axisdefaultheight,
% % if the plot should fill the whole page, try the following key
% scale mode=stretch to fill,
]
%\pgftransformxscale{1.5}%scales in xdirection but stretches also the font
\addplot table [x=Year, y=pid, fill=green] {\table} \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}