2

I have the following:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document} \begin{tikzpicture} \begin{axis}[ xbar, xmin=0, xmax=290, xlabel={Mentions}, ylabel={Title words}, symbolic y coords={ {Devices}, {Data}, {Scheme}, {Authentication}, {Key}, {Secure}, {Lightweight}, {Security}, {Elliptic Curve Cryptography}, {Wireless Sensor Networks}, {Internet of Things}, {Cryptography} }, ytick=data, nodes near coords, nodes near coords align={horizontal}, ] \addplot coordinates { (33,{Devices}) (47,{Data}) (49,{Scheme}) (52,{Authentication}) (61,{Key}) (68,{Secure}) (73,{Lightweight}) (78,{Security}) (111,{Elliptic Curve Cryptography}) (115,{Wireless Sensor Networks}) (246,{Internet of Things}) (257,{Cryptography}) }; \end{axis} \end{tikzpicture} \end{document}

I want to color some bars of this chart in a different color. The fact that there is a single \addplot command along with that there are symbolic coordinates, makes it pretty difficult for me.

bar chart

twit
  • 53
  • 1
    maybe have a look if https://tex.stackexchange.com/questions/58548/is-it-possible-to-change-the-color-of-a-single-bar-when-the-bar-plot-is-based-on could help – samcarter_is_at_topanswers.xyz Jan 26 '23 at 11:50
  • Works, thanks! I cannot mark as solved, could you post it as an answer? – twit Jan 26 '23 at 13:59
  • You're welcome! I suggested to mark the post as duplicate. This way your question will a signpost to help other users with the same problem to find a solution. – samcarter_is_at_topanswers.xyz Jan 26 '23 at 14:01
  • I want to color multiple bars, this suggestion only works for a single bar. Furthermore, https://tex.stackexchange.com/questions/301985/filter-pgfplots-data-more-than-once-e-g-with-discard-if does not work for me either. Can you figure this out? https://pastebin.com/1etM75gr – twit Jan 26 '23 at 15:00

0 Answers0