tikz 图中的 \texttt

tikz 图中的 \texttt

有没有办法让它正常工作?似乎使用 \texttt 不起作用

\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
    ymin=0, ymax=100,
    ymajorgrids = true,
    axis x line*=bottom,
    axis y line*=left,
    tickwidth=0pt,
    symbolic x coords={\texttt{cv}, \texttt{pT}, $\widetilde{pT}$,, \texttt{ev}, \texttt{ev(cv)}},
    ylabel={CI (\%)},
    xtick={\texttt{cv}, \texttt{pT}, $\widetilde{pT}$,, \texttt{ev}, \texttt{ev(cv)}},
    xticklabel style={rotate=90}]
    \addplot[ybar,fill=blue] coordinates {
        (\texttt{cv},26.355)
        ($\widetilde{pT}$,100)
        (\texttt{pT},35.55114)
    };
    \addplot[ybar,fill=orange] coordinates {
        (\texttt{ev(cv)},63.17104)
        (\texttt{ev},93.775)
    };
\end{axis}
\end{tikzpicture}
\end{figure}

答案1

您可能不应该为符号坐标设置样式(尽管在某些情况下这可能有效)。但您当然可以为其标签设置样式:

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    ymin=0, ymax=100,
    ymajorgrids = true,
    axis x line*=bottom,
    axis y line*=left,
    tickwidth=0pt,
    symbolic x coords={cv, pT, pTn,, ev, evcv},
    ylabel={CI (\%)},
    xticklabels={, \texttt{cv}, \texttt{pT}, $\widetilde{pT}$,, \texttt{ev}, \texttt{ev(cv)}},
    xticklabel style={rotate=90}]
    \addplot[ybar,fill=blue] coordinates {
        (cv,26.355)
        (pTn,100)
        (pT,35.55114)
    };
    \addplot[ybar,fill=orange] coordinates {
        (evcv,63.17104)
        (ev,93.775)
    };
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容