我有一个带有“{}”的数据表,我想保留这些字符。
我想从解析中取消忽略这个字符并将其打印在图像上。
我知道我可以改变:
nodes near coords*={\label},
到
nodes near coords*={\{\label\}},
但这不允许我打印类似 {{N}{F}} 的内容
我当前的乳胶代码:
\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{xparse}
\usetikzlibrary{3d}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage[utf8]{inputenc} %unicode support
\usepackage{lmodern}
\usepackage{graphicx}
\pgfplotsset{width=7cm,compat=1.12}
\begin{tikzpicture}
\begin{axis}[
separate axis lines,
axis lines=left,
every outer x axis line/.append style={-stealth},
every outer y axis line/.append style={-stealth},
xmin=-1,xmax=7,
ymin=-1,ymax=7,
xticklabels=\empty,
yticklabels=\empty,
zticklabels=\empty,
xlabel=$t$,
ylabel=$i$
]
\addplot[
nodes near coords*={\label},
nodes near coords align={right},
every node near coord/.style={font=\tiny,black},
mark=*,
only marks,
scatter,
visualization depends on={value \thisrow{label} \as \label}
] table[x=t,y=i,meta=label]{
t f i label
0 6 0 {F}
6 0 0 {T}
3 3 0 {N}
3 3 3 {FT}
0 6 3 {NF}
6 0 3 {NT}
3 3 6 {NFT}
};
% F - FT
\draw[black,-] (0,0) to (3,3);
% F - NF
\draw[black,-] (0,0) to (0,3);
% NF - NFT
\draw[black,-] (0,3) to (3,6);
% NFT - FT
\draw[black,-] (3,6) to (3,3);
% NFT - NT
\draw[black,-] (3,6) to (6,3);
% NT - T
\draw[black,-] (6,3) to (6,0);
% T - FT
\draw[black,-] (6,0) to (3,3);
% N - NF
\draw[black,-] (3,0) to (0,3);
% N - NT
\draw[black,-] (3,0) to (6,3);
\end{axis}
\end{tikzpicture}
\end{document}
感谢您的帮助
答案1
如果你想打印括号中,你必须告诉 LaTeX:将数据更改为
t f i label
0 6 0 \{F\}
6 0 0 \{T\}
3 3 0 \{N\}
3 3 3 \{FT\}
0 6 3 \{NF\}
6 0 3 \{NT\}
3 3 6 \{NFT\}
你会得到
这是完整代码。我只是在相关位置将{
和}
改为\{
和 ,并添加了。\}
\begin{document}
\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{xparse}
\usetikzlibrary{3d}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage[utf8]{inputenc} %unicode support
\usepackage{lmodern}
\usepackage{graphicx}
\pgfplotsset{width=7cm,compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
separate axis lines,
axis lines=left,
every outer x axis line/.append style={-stealth},
every outer y axis line/.append style={-stealth},
xmin=-1,xmax=7,
ymin=-1,ymax=7,
xticklabels=\empty,
yticklabels=\empty,
zticklabels=\empty,
xlabel=$t$,
ylabel=$i$
]
\addplot[
nodes near coords*={\label},
nodes near coords align={right},
every node near coord/.style={font=\tiny,black},
mark=*,
only marks,
scatter,
visualization depends on={value \thisrow{label} \as \label}
] table[x=t,y=i,meta=label]{
t f i label
0 6 0 \{F\}
6 0 0 \{T\}
3 3 0 \{N\}
3 3 3 \{FT\}
0 6 3 \{NF\}
6 0 3 \{NT\}
3 3 6 \{NFT\}
};
% F - FT
\draw[black,-] (0,0) to (3,3);
% F - NF
\draw[black,-] (0,0) to (0,3);
% NF - NFT
\draw[black,-] (0,3) to (3,6);
% NFT - FT
\draw[black,-] (3,6) to (3,3);
% NFT - NT
\draw[black,-] (3,6) to (6,3);
% NT - T
\draw[black,-] (6,3) to (6,0);
% T - FT
\draw[black,-] (6,0) to (3,3);
% N - NF
\draw[black,-] (3,0) to (0,3);
% N - NT
\draw[black,-] (3,0) to (6,3);
\end{axis}
\end{tikzpicture}
\end{document}