Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. usepackage{tikz,pgfplots,pgfplotstable}
  2.  
  3. begin{document}
  4.  
  5. pgfplotstableread{ % data
  6. Label Adequacy Sustainability Integrity
  7. Austria 21.87797 5.566584 24.85545
  8. Brazil 20.93009 7.937881 24.33203
  9. Chile 20.41148 21.126529 27.56199
  10. Australia 26.83072 23.823827 28.94545
  11. }testdata
  12.  
  13. begin{tikzpicture}
  14.  
  15. begin{axis}[
  16. xbar stacked, % Stacked horizontal bars
  17. xmin=0, % Start x axis at 0
  18. ytick=data, % Use as many tick labels as y coordinates
  19. legend style={at={(axis cs:65,0.2)},anchor=south west},
  20.  
  21. yticklabels from table={testdata}{Label} % Get the labels from the Label column of the datatable
  22. ]
  23. addplot [fill=green!80] table [x=Adequacy, meta=Label,y expr=coordindex] {testdata}; % "First" column against the data index
  24. addplot [fill=blue!60] table [x=Sustainability, meta=Label,y expr=coordindex] {testdata};
  25. addplot [fill=red!60,
  26. point meta=x,
  27. nodes near coords,
  28. nodes near coords align={anchor=west},
  29. every node near coord/.append style={
  30. black,
  31. fill=white,
  32. fill opacity=0.75,
  33. text opacity=1,
  34. outer sep=pgflinewidth % so the label fill doesn't overlap the plot
  35. }
  36. ] table [x=Integrity, meta=Label,y expr=coordindex] {testdata};
  37. legend{Adequacy,Sustainability,Integrity}
  38.  
  39. end{axis}
  40. end{tikzpicture}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement