水平 pgfplot (xbar) 删除条形标签

Horizontal pgfplot (xbar) remove bar labels

我想在乳胶中创建水平条形图。我已经有了以下内容,但我想删除条形末尾的值标签。

有人可以帮助我们解决这个问题吗?提前致谢!

我的代码:

\documentclass[a4paper, 11pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{float}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{font=\footnotesize}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
    xlabel={Importance},
    symbolic y coords={LASTRESPONSETYPESINGLEGIFTMANDATE,RECENCYTARGETEDDAYS,LASTRESPONSETYPEMANDATE,REGIONUNKNOWN,MAXDM,TOTALGIFTS,FREQUENCYRESPONSE,LASTGIFTAMOUNT,DAYSSINCEFIRSTGIFT,STATUSRESPONSEACTIVEACTIVE,ACTIVEMANDATECHECKEX-MANDATE,RECENCYRESPONSEDAYS,FREQUENCYTARGETED,FIRSTGIFTSINGLE,YTDFREQUENCYRESPONSE,LASTRESPONSETYPESINGLEGIFT,ACTIVEMANDATECHECKNOMANDATE,GENDERMALE,GENDERUNKNOWN,MONTH,STATUSRESPONSEACTIVENEW,ACTIVEMANDATECHECKACTIVE,YTDFREQUENCYTARGETED,RESPONSERATIO,LASTRESPONSETYPENEW,LASTRESPONSETYPENORESPONSE,GENDERFEMALE,STATUSRESPONSEACTIVEINACTIVE,REGIONNORTH,REGIONWEST,BIRTHYEARCATEGORYUNKNOWN,BIRTHYEARCATEGORYVERYOLD,BIRTHYEARCATEGORYYOUNG,REGIONEAST,REGIONSOUTH,BIRTHYEARCATEGORYMIDDLE,BIRTHYEARCATEGORYOLD},
    ytick=data,
    xbar,
    bar width=3pt,
    xmin=0,
    enlarge y limits,
    height=16cm, width=9cm,
    nodes near coords, nodes near coords align={horizontal}]

  \addplot coordinates {
    (6.94,LASTRESPONSETYPESINGLEGIFTMANDATE)(9.52,RECENCYTARGETEDDAYS)(12.46,LASTRESPONSETYPEMANDATE)(14.77,REGIONUNKNOWN)(15.26,MAXDM)(16.35,TOTALGIFTS)(17.19,FREQUENCYRESPONSE)(17.72,LASTGIFTAMOUNT)(17.97,DAYSSINCEFIRSTGIFT)(18.09,STATUSRESPONSEACTIVEACTIVE)(18.34,ACTIVEMANDATECHECKEX-MANDATE)(19.43,RECENCYRESPONSEDAYS)(19.74,FREQUENCYTARGETED)(20.2,FIRSTGIFTSINGLE)(20.66,YTDFREQUENCYRESPONSE)(21.41,LASTRESPONSETYPESINGLEGIFT)(21.44,ACTIVEMANDATECHECKNOMANDATE)(22.89,GENDERMALE)(23.88,GENDERUNKNOWN)(24.82,MONTH)(25.12,STATUSRESPONSEACTIVENEW)(25.91,ACTIVEMANDATECHECKACTIVE)(26.31,YTDFREQUENCYTARGETED)(26.71,RESPONSERATIO)(30.65,LASTRESPONSETYPENEW)(31.66,LASTRESPONSETYPENORESPONSE)(32.61,GENDERFEMALE)(37.14,STATUSRESPONSEACTIVEINACTIVE)(43.36,REGIONNORTH)(50.05,REGIONWEST)(51.16,BIRTHYEARCATEGORYUNKNOWN)(53.3,BIRTHYEARCATEGORYVERYOLD)(53.67,BIRTHYEARCATEGORYYOUNG)(58.62,REGIONEAST)(63.79,REGIONSOUTH)(72.32,BIRTHYEARCATEGORYMIDDLE)(77.05,BIRTHYEARCATEGORYOLD)
  };
  \addplot coordinates {
    (0.07,RECENCYRESPONSEDAYS)(0.13,RECENCYTARGETEDDAYS)(0.15,LASTRESPONSETYPESINGLEGIFTMANDATE)(0.81,LASTRESPONSETYPEMANDATE)(1.99,ACTIVEMANDATECHECKEX-MANDATE)(2.14,ACTIVEMANDATECHECKNOMANDATE)(2.74,REGIONUNKNOWN)(3.12,ACTIVEMANDATECHECKACTIVE)(3.77,MAXDM)(4.79,DAYSSINCEFIRSTGIFT)(7.97,FIRSTGIFTSINGLE)(7.97,TOTALGIFTS)(8.2,STATUSRESPONSEACTIVEACTIVE)(8.52,FREQUENCYRESPONSE)(8.65,LASTRESPONSETYPESINGLEGIFT)(10.98,FREQUENCYTARGETED)(11.04,GENDERUNKNOWN)(11.22,LASTRESPONSETYPENEW)(11.23,MONTH)(11.48,YTDFREQUENCYRESPONSE)(11.85,LASTRESPONSETYPENORESPONSE)(13.08,GENDERMALE)(13.25,LASTGIFTAMOUNT)(13.7,YTDFREQUENCYTARGETED)(14.8,STATUSRESPONSEACTIVENEW)(15.1,RESPONSERATIO)(15.22,STATUSRESPONSEACTIVEINACTIVE)(17.01,GENDERFEMALE)(36.22,REGIONNORTH)(37.07,BIRTHYEARCATEGORYUNKNOWN)(45.06,BIRTHYEARCATEGORYVERYOLD)(45.54,BIRTHYEARCATEGORYYOUNG)(45.82,REGIONWEST)(50.67,REGIONEAST)(56.05,REGIONSOUTH)(62.73,BIRTHYEARCATEGORYMIDDLE)(65.16,BIRTHYEARCATEGORYOLD)
  };

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

标签由nodes near coords键添加。如果您不想在那里有标签,只需将其删除即可。

\documentclass[a4paper, 11pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{float}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{font=\footnotesize}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
    xlabel={Importance},
    symbolic y coords={LASTRESPONSETYPESINGLEGIFTMANDATE,RECENCYTARGETEDDAYS,LASTRESPONSETYPEMANDATE,REGIONUNKNOWN,MAXDM,TOTALGIFTS,FREQUENCYRESPONSE,LASTGIFTAMOUNT,DAYSSINCEFIRSTGIFT,STATUSRESPONSEACTIVEACTIVE,ACTIVEMANDATECHECKEX-MANDATE,RECENCYRESPONSEDAYS,FREQUENCYTARGETED,FIRSTGIFTSINGLE,YTDFREQUENCYRESPONSE,LASTRESPONSETYPESINGLEGIFT,ACTIVEMANDATECHECKNOMANDATE,GENDERMALE,GENDERUNKNOWN,MONTH,STATUSRESPONSEACTIVENEW,ACTIVEMANDATECHECKACTIVE,YTDFREQUENCYTARGETED,RESPONSERATIO,LASTRESPONSETYPENEW,LASTRESPONSETYPENORESPONSE,GENDERFEMALE,STATUSRESPONSEACTIVEINACTIVE,REGIONNORTH,REGIONWEST,BIRTHYEARCATEGORYUNKNOWN,BIRTHYEARCATEGORYVERYOLD,BIRTHYEARCATEGORYYOUNG,REGIONEAST,REGIONSOUTH,BIRTHYEARCATEGORYMIDDLE,BIRTHYEARCATEGORYOLD},
    ytick=data,
    xbar,
    bar width=3pt,
    xmin=0,
    enlarge y limits,
    height=16cm, width=9cm,
%    nodes near coords, nodes near coords align={horizontal}
    ]

  \addplot coordinates {
    (6.94,LASTRESPONSETYPESINGLEGIFTMANDATE)(9.52,RECENCYTARGETEDDAYS)(12.46,LASTRESPONSETYPEMANDATE)(14.77,REGIONUNKNOWN)(15.26,MAXDM)(16.35,TOTALGIFTS)(17.19,FREQUENCYRESPONSE)(17.72,LASTGIFTAMOUNT)(17.97,DAYSSINCEFIRSTGIFT)(18.09,STATUSRESPONSEACTIVEACTIVE)(18.34,ACTIVEMANDATECHECKEX-MANDATE)(19.43,RECENCYRESPONSEDAYS)(19.74,FREQUENCYTARGETED)(20.2,FIRSTGIFTSINGLE)(20.66,YTDFREQUENCYRESPONSE)(21.41,LASTRESPONSETYPESINGLEGIFT)(21.44,ACTIVEMANDATECHECKNOMANDATE)(22.89,GENDERMALE)(23.88,GENDERUNKNOWN)(24.82,MONTH)(25.12,STATUSRESPONSEACTIVENEW)(25.91,ACTIVEMANDATECHECKACTIVE)(26.31,YTDFREQUENCYTARGETED)(26.71,RESPONSERATIO)(30.65,LASTRESPONSETYPENEW)(31.66,LASTRESPONSETYPENORESPONSE)(32.61,GENDERFEMALE)(37.14,STATUSRESPONSEACTIVEINACTIVE)(43.36,REGIONNORTH)(50.05,REGIONWEST)(51.16,BIRTHYEARCATEGORYUNKNOWN)(53.3,BIRTHYEARCATEGORYVERYOLD)(53.67,BIRTHYEARCATEGORYYOUNG)(58.62,REGIONEAST)(63.79,REGIONSOUTH)(72.32,BIRTHYEARCATEGORYMIDDLE)(77.05,BIRTHYEARCATEGORYOLD)
  };
  \addplot coordinates {
    (0.07,RECENCYRESPONSEDAYS)(0.13,RECENCYTARGETEDDAYS)(0.15,LASTRESPONSETYPESINGLEGIFTMANDATE)(0.81,LASTRESPONSETYPEMANDATE)(1.99,ACTIVEMANDATECHECKEX-MANDATE)(2.14,ACTIVEMANDATECHECKNOMANDATE)(2.74,REGIONUNKNOWN)(3.12,ACTIVEMANDATECHECKACTIVE)(3.77,MAXDM)(4.79,DAYSSINCEFIRSTGIFT)(7.97,FIRSTGIFTSINGLE)(7.97,TOTALGIFTS)(8.2,STATUSRESPONSEACTIVEACTIVE)(8.52,FREQUENCYRESPONSE)(8.65,LASTRESPONSETYPESINGLEGIFT)(10.98,FREQUENCYTARGETED)(11.04,GENDERUNKNOWN)(11.22,LASTRESPONSETYPENEW)(11.23,MONTH)(11.48,YTDFREQUENCYRESPONSE)(11.85,LASTRESPONSETYPENORESPONSE)(13.08,GENDERMALE)(13.25,LASTGIFTAMOUNT)(13.7,YTDFREQUENCYTARGETED)(14.8,STATUSRESPONSEACTIVENEW)(15.1,RESPONSERATIO)(15.22,STATUSRESPONSEACTIVEINACTIVE)(17.01,GENDERFEMALE)(36.22,REGIONNORTH)(37.07,BIRTHYEARCATEGORYUNKNOWN)(45.06,BIRTHYEARCATEGORYVERYOLD)(45.54,BIRTHYEARCATEGORYYOUNG)(45.82,REGIONWEST)(50.67,REGIONEAST)(56.05,REGIONSOUTH)(62.73,BIRTHYEARCATEGORYMIDDLE)(65.16,BIRTHYEARCATEGORYOLD)
  };

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