50x150-k1
내 데이터는 다음과 같이 실제로 명확하게 표시되지 않습니다. 또는 오류 수염을 볼 수 없습니다 50x150-k1
. 이는 (분명히) 이 값이 40x150-k
. 나는 x축을 로그로 만들 수 있다고 생각했지만(아래 예에서처럼) 이것은 별로 도움이 되지 않았습니다. 나는 비슷한 kdelta 값을 가지고 있기 때문에 오류가 50x150-k2
(눈에 띄게) 거의 와 비슷할 것으로 예상합니다.16x75-s
수염은 표에 따라 k-1과 k+1로 주어지며, kdelta는 k+1 / k-1입니다.
이미지의 그래프를 생성하는 코드는 다음과 같습니다.
\pgfplotstableread{data.txt}\data
\pgfplotstableset{create on use/error/.style={
create col/expr={\thisrow{uci}-\thisrow{mean}}
}
}
\begin{tikzpicture}[trim axis left,trim axis right]
\begin{axis}[y=-\baselineskip,
scale only axis,
width = 7cm,
enlarge y limits = {abs=0.5},
axis y line* = middle,
y axis line style = dashed,
ytick = \empty,
axis x line* = bottom,
xmode=log,
]
\addplot+[only marks][error bars/.cd,x dir=both, x explicit]
table [x=mean,y expr=\coordindex,x error=error]{\data};
\end{axis}
\end{tikzpicture}
오류 마진을 더 잘 나타내는 코드는 무엇입니까? 나는 여전히 log10이 정확할 것으로 기대하고 있습니다.
전체 코드 및 데이터:
\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[swedish]{babel}
\usepackage{stix} % font
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{
output-exponent-marker = \ensuremath{\mathrm{e}},
exponent-product={},
retain-explicit-plus
}
% Read data file, create new column ``upper CI boundary - mean''
\pgfplotstableread{data.txt}\data
\pgfplotstableset{create on use/error/.style={
create col/expr={\thisrow{uci}-\thisrow{mean}}
}
}
% Define the command for the plot
\newcommand{\errplot}{%
\begin{tikzpicture}[trim axis left,trim axis right]
\begin{axis}[y=-\baselineskip,
scale only axis,
width = 7cm,
enlarge y limits = {abs=0.5},
axis y line* = middle,
y axis line style = dashed,
ytick = \empty,
axis x line* = bottom,
xmode=log,
]
% ``mean'' must be present in the datafile,
%``error'' is the newly generated column
\addplot+[only marks][error bars/.cd,x dir=both, x explicit]
table [x=mean,y expr=\coordindex,x error=error]{\data};
\end{axis}
\end{tikzpicture}%
}
\begin{document}
% Get number of rows in datafile
\pgfplotstablegetrowsof{\data}
\let\numberofrows=\pgfplotsretval
% Print the table
\pgfplotstabletypeset[columns={name,error,mean,lci, uci, frac},
% Booktabs rules
every head row/.style={
before row={%
\toprule
& \textbf{Felmarginaler} $\log_{10}$& & \multicolumn{3}{c}{\textbf{Värden för \mu_i \pm 1\%}} \\
\cmidrule(lr){4-6}
},
after row={ \midrule},
},
every last row/.style = {after row=[3ex]\bottomrule},
% Set header name
columns/name/.style = {string type, column name=\textbf{ID}},
% Use the ``error'' column to call the \errplot command in a multirow cell
% in the first row, keep empty for all other rows
columns/error/.style = {
column name = {},
assign cell content/.code = {% use \multirow for Z column:
\ifnum\pgfplotstablerow=0
\pgfkeyssetvalue{/pgfplots/table/@cell content}
{\multirow{\numberofrows}{6.5cm}{\errplot}}%
\else
\pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
\fi
}
},
columns/mean/.style = {
column name = $k$,
string type,
column type={S},
},
columns/lci/.style = {
column name = $k_{-1}$,
string type,
column type={c},
},
columns/uci/.style = {
column name = $k_{+1}$,
string type,
column type={c},
},
columns/frac/.style = {
column name = $k_{\Delta}$,
string type,
},
]{\data}
\end{document}
data.txt에서:
name mean lci uci frac
16x75-s-k 1.18e-3 9.85e-4 1.50e-3 152\%
40x150-k 3.07e-4 1.76e-4 4.37e-4 248\%
50x150-k$_{1}$ 6.45e-4 5.76e-4 6.50e-4 112\%
50x150-k$_{2}$ 5.94e-5 4.71e-5 6.00e-5 127\%
답변1
찾고 계시는 것 같아요
x error plus=uci,x error minus=lci
가려고
\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[swedish]{babel}
\usepackage{stix} % font
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{
output-exponent-marker = \ensuremath{\mathrm{e}},
exponent-product={},
retain-explicit-plus
}
% Read data file, create new column ``upper CI boundary - mean''
\pgfplotstableread{data.txt}\data
\pgfplotstableset{create on use/error/.style={
create col/expr={\thisrow{uci}-\thisrow{mean}}
}
}
% Define the command for the plot
\newcommand{\errplot}{%
\begin{tikzpicture}[trim axis left,trim axis right]
\begin{axis}[y=-\baselineskip,
scale only axis,
width = 7cm,
enlarge y limits = {abs=0.5},
axis y line* = middle,
y axis line style = dashed,
ytick = \empty,
axis x line* = bottom,
xmode=log,
]
% ``mean'' must be present in the datafile,
%``error'' is the newly generated column
\addplot+[only marks][error bars/.cd,x dir=both, x explicit]
table [x=mean,y expr=\coordindex,
x error plus=uci,x error minus=lci]{\data};
\end{axis}
\end{tikzpicture}%
}
\begin{document}
% Get number of rows in datafile
\pgfplotstablegetrowsof{\data}
\let\numberofrows=\pgfplotsretval
% Print the table
\pgfplotstabletypeset[columns={name,error,mean,lci, uci, frac},
% Booktabs rules
every head row/.style={
before row={%
\toprule
& \textbf{Felmarginaler} $\log_{10}$& &
\multicolumn{3}{c}{\textbf{V\"arden f\"or $\mu_i \pm 1\%$}} \\
\cmidrule(lr){4-6}
},
after row={ \midrule},
},
every last row/.style = {after row=[3ex]\bottomrule},
% Set header name
columns/name/.style = {string type, column name=\textbf{ID}},
% Use the ``error'' column to call the \errplot command in a multirow cell
% in the first row, keep empty for all other rows
columns/error/.style = {
column name = {},
assign cell content/.code = {% use \multirow for Z column:
\ifnum\pgfplotstablerow=0
\pgfkeyssetvalue{/pgfplots/table/@cell content}
{\multirow{\numberofrows}{6.5cm}{\errplot}}%
\else
\pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
\fi
}
},
columns/mean/.style = {
column name = $k$,
string type,
column type={S},
},
columns/lci/.style = {
column name = $k_{-1}$,
string type,
column type={c},
},
columns/uci/.style = {
column name = $k_{+1}$,
string type,
column type={c},
},
columns/frac/.style = {
column name = $k_{\Delta}$,
string type,
},
]{\data}
\end{document}
제가 주요 요점에 초점을 맞추고 $
코드를 컴파일하기 위해 두 개를 추가했다는 점에 주목하세요. 코드를 추가로 조정할 수 있습니다.