
MWE에 표시된 것처럼 불완전한 테스트 데이터가 있습니다. 플롯에서 사용 가능한 모든 데이터 포인트(즉, 구리에 대해 (55.16, 0.08))를 사용하고 싶지만 플롯에서는 이를 고려하지 않습니다. 또한 쉼표 구분 기호와 같은 전역 옵션은 작동하지 않습니다(기본 y =0.5 y 눈금 레이블에만 작동하지만 추가된 y 눈금 레이블에는 작동하지 않습니다. (그러나 매뉴얼의 플롯 중 하나에서는 제대로 작동하므로) 문제는 내 데이터 및/또는 플롯 옵션에 있으며 아마도 의미가 있는 "표시만" 옵션을 플롯에서 사용할 수 없었습니다.
\documentclass[]{scrartcl}
\usepackage{siunitx}
\usepackage{filecontents}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest,
every linear axis/.append style={
/pgf/number format/use comma,
/pgf/number format/fixed,
}}
\begin{document}
\begin{filecontents}{data-W.csv}
{Stress};{Aluminium};{Copper}
3.44;0.0015;0.001
6.89;0.1;0.002
10.34;0.2;
11.72; ;0.0068
13.79; ;
15.51;0.5;
17.24; ;
20.68;1;0.01
24.13; ;
27.58; ;
31.03; ;
34.47; ;
37.92; ;
41.37; ;0.04
44.82; ;
48.26; ;
55.16; ;0.08
\end{filecontents}
\pgfplotstableread[col sep=semicolon]{data-W.csv}{\datatableW}
\begin{tikzpicture}
\begin{axis}[
height=.5\textwidth, width=\textwidth,
xticklabel style= {font={\small}},
grid=both,
%xticklabels from table={\datatableW}{[index]0}, %does not accept plot settings
extra y ticks={.1,.3,.5,.7,.9}, % Did not accept global option but now does
%extra y tick labels={.1,.3,.5,.7,.9} % not necessary now
xlabel={Stress (\si{\mega\pascal})},
ylabel={Relaxation (\%)},
legend entries={Pure aluminium,Copper}, ]
\addplot [blue,only marks] table [
x index =0, y index=1] {\datatableW};
% x expr=\coordindex, x index =0,{\datatableW}; % Incorrect
\addplot [red,] table [
x index =0,
%x expr=\coordindex, x index =0, % incorrect
y index=2] {\datatableW};
\end{axis} \end{tikzpicture}
\end{document}
답변1
문제를 일으킨 플롯 옵션(및 일반 플롯 설정의 모순)에 몇 가지 실수가 있었습니다. 이를 강조하고 수정하기 위해 코드를 편집했습니다. 왜 옵션이 선택되었는지는 아직 불분명합니다.
xticklabels from table={\datatableW}{[index]0}
전역 플롯 설정을 허용하지 않는 것 같지만 이를 제거하면 플롯이 더 평범하고 보기 좋고 논리적이 됩니다.