删除 pgfplot 中的轴刻度

删除 pgfplot 中的轴刻度

我使用下面的代码创建了一个堆叠条形图。图表创建正确,但我想删除每个标签附近的小线条(见下图)。我想保留数字,但没有小线条。提前谢谢您!

\documentclass[border=5mm] {standalone}\usepackage{pgfplots, pgfplotstable}

\begin{document}

\begin{tikzpicture}
    \pgfplotstableread{
    T myCol
    1000 0.3
    10000 0.4
    }
    {\loadedtable}
\begin{axis}[
    ybar stacked,   % Stacked horizontal bars
    ymin=0,         % Start x axis at 0
    xtick=data,     % Use as many tick labels as y coordinates
    xticklabels from table={\loadedtable}{T},  % Get the labels from the Label column of the \datatable
    ]
    \addplot [fill=blue] table [y=myCol, meta=T,x expr=\coordindex] {\loadedtable}; 

\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

您可以使用ytick style={draw=none}ytick style={/pgfplots/major tick length=0pt}来获取

\documentclass[border=5mm] {standalone}\usepackage{pgfplots, pgfplotstable}

\begin{document}

\begin{tikzpicture}
    \pgfplotstableread{
    T myCol
    1000 0.3
    10000 0.4
    }
    {\loadedtable}
\begin{axis}[ytick style={draw=none},
    %ytick style={/pgfplots/major tick length=0pt},%<-alternative
    ybar stacked,   % Stacked horizontal bars
    ymin=0,         % Start x axis at 0
    xtick=data,     % Use as many tick labels as y coordinates
    xticklabels from table={\loadedtable}{T},  % Get the labels from the Label column of the \datatable
    ]
    \addplot [fill=blue] table [y=myCol, meta=T,x expr=\coordindex] {\loadedtable}; 

\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容