디스크에서 CSV 파일을 읽은 다음 읽은 테이블을 전치하고 싶습니다. 내 문서에 테이블을 만들 때 명령에 문제가 없습니다 pgfplotstabletranspose
. 그러나 디스크에서 파일을 읽으려고 하면 다음과 같은 오류가 발생합니다.
패키지 pgfplots 오류: 죄송합니다. 'attachments/paper_survey.csv' 테이블에서 'Label' 열을 검색할 수 없습니다. 철자를 확인하세요(또는 이름 별칭을 입력하세요)..
이것은 내 MWE입니다.
\documentclass[]{article}
\usepackage{pgfplots,pgfplotstable}
\begin{document}
\pgfplotstableread[col sep=semicolon]{% Read the data into a table macro
Label;A;B;C;D;E;F;G;H;I;J;K;L;M;N;O
Yes;0.00;0.20;0.00;0.26;0.11;0.00;;0.49;0.14;0.31;0.03;0.60;0.06;0.06;0.00
No;1.00;0.80;1.00;0.74;0.89;1.00;;0.51;0.86;0.69;0.97;0.40;0.94;0.94;0.00
High;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.26
Medium;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.21
Low;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.53
}\datatable
% \pgfplotstableread[col sep = semicolon]{attachments/paper_survey.csv}\datatable
\pgfplotstabletranspose[string type,
colnames from=Label,
input colnames to=Label
]\datatabletransposed{\datatable}
\end{document}
이 문제를 어떻게 해결할 수 있나요?
답변1
첨부 파일 하위 폴더의 데이터를 실행하는 데 문제가 없습니다.
빈 예/아니요 슬롯이 있고 "O" 값이 0이므로 "G" 값을 확인하는 것이 좋습니다.
이 조합이 나에게 효과적이었으므로 하위 폴더/파일 이름이 올바른지 다시 확인하세요.
mainTeX폴더/첨부 파일/paper_survey.csv
Label;A;B;C;D;E;F;G;H;I;J;K;L;M;N;O
Yes;0.00;0.20;0.00;0.26;0.11;0.00;0.0;0.49;0.14;0.31;0.03;0.60;0.06;0.06;0.00
No;1.00;0.80;1.00;0.74;0.89;1.00;0.0;0.51;0.86;0.69;0.97;0.40;0.94;0.94;0.00
High;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.26
Medium;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.21
Low;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.53
플롯 방법을 선택하지 않았으므로 이전 질문과 동일한 방법을 사용했습니다.
\documentclass[]{article}
\usepackage{pgfplots,pgfplotstable}
\pgfplotsset{compat=1.16}
\begin{document}
\pgfplotstableread[col sep = semicolon]{attachments/paper_survey.csv}\datatable
\begin{tikzpicture}
\pgfplotstabletranspose[string type, colnames from=Label, input colnames to=Label]\datatabletransposed{\datatable}
\begin{axis}[
xbar stacked, % Stacked horizontal bars
xmin=0, % Start x axis at 0
ytick=data, % Use as many tick labels as y coordinates
yticklabels from table={\datatabletransposed}{Label} % Get the labels from the Label column of the \datatable
]
\addplot [fill=green!70!blue] table [x=Yes, y expr=\coordindex] {\datatabletransposed};
\addplot [fill=red!70!blue] table [x=No, y expr=\coordindex] {\datatabletransposed};
\end{axis}
\end{tikzpicture}
\end{document}