# Tag Info

36

To decrease the space between the groups, you can increase the x axis range by using enlarge x limits=0.25 (which increases the axis range by 25% compared to the data range). To remove the spacing between the bars, use ybar=0pt instead of just ybar. Note that this will lead to slight overlaps between the bars due to their outlines. To avoid this, you could ...

36

The pgfplots manual gives a lot of information and tutorials- you'll also find a lot of great examples on this site. Here's a humble tutorial on how I created the following bar graph, which I used in answering How to clarify and enliven a dense table using the wonderful pgfplots package; the complete code is given at the end. Reading the data The first ...

32

You can set the spacing between the bars using the optional argument to ybar (the default is 2pt). For indicating that some of the data values exceed the axis range, you could clip the values at some level that's slightly larger than your axis limit using restrict y to domain*=0:<value>, making sure that you set clip=false so that the bars can ...

29

For bar charts you can use pgfplots With TikZ you can setup some macros so that you can write pie charts like this: \begin{tikzpicture} [ pie chart, slice type={comet}{blu}, slice type={legno}{rosso}, slice type={coltello}{giallo}, slice type={sedia}{viola}, slice type={caffe}{verde}, pie values/.style={font={\small}}, scale=...

26

Instead of trying to populate the list of permitted symbolic coordinates, I would recommend to use the xticklabels from table key to set the labels. You don't need to provide an explicit ID column for this to work, you can just use x expr=\coordindex. As long as you also use xtick=data, the labels will always be assigned to the correct bars. \documentclass{...

23

You can use the PGFPlots statistics library for this: \documentclass[border=5mm]{standalone} \usepackage{filecontents} \usepackage{pgfplots, pgfplotstable} \usepgfplotslibrary{statistics} \begin{filecontents}{data.csv} dist 1 2 2.5 2 1 3.5 3 1 3 2 1 1 0.5 1 1.5 1 \end{filecontents} \begin{document} \begin{tikzpicture} \begin{axis}[ ybar, ymin=0 ] \...

18

By default, plots always take up the same amount of space (240pt by 207pt). If you want the plots to adjust their height depending on the number of bars, you can define the length of a unit in the y direction, by setting y=0.5cm, for instance. If you then define the bar width to be 0.4cm, there will be no overlap between the bars. Since PGFPlots version 1.7 (...

17

PGFPlots is printing the log transformed x value. To print the non transformed value, set point meta=rawx. (Similarly for ybar, use point meta=rawy to get the raw y value.) Note that bar plots with logarithmic axes are a really bad idea, since the zero point of logarithmic plots is arbitrary and the length of the bar doesn't carry any information. A dot ...

16

You can use yticklabel style={/pgf/number format/fixed}: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \centering \begin{axis}[ width=300pt, height=250pt, axis lines*=left, % Don't display the top and right lines ybar, % Display it as a bargraph enlarge y limits={upper,value=0.2}, legend style={...

15

How about something like this: \documentclass{article} \usepackage{amsmath,amssymb} \usepackage{array} \usepackage{xcolor} \def\mybar#1{%% #1s & {\color{red}\rule{#1cm}{8pt}}} \pagestyle{empty} \begin{document} \begin{tabular}{>{$\rhd$ }lrl} Loop at line 151 in divergence & \mybar{3.420}\\ Loop at line 1071 in radiation & \mybar{3.270}\\...

14

You can reverse the order of the legend entries by setting reverse legend: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[xbar, reverse legend] \addplot coordinates {(2.659244418,1)}; \addlegendentry{A} \addplot coordinates {(18.95781994,1)}; \addlegendentry{B} \end{axis} \end{tikzpicture} \end{...

13

I can think of two things: Anchor the labels at the north east rather than the east. Northeast makes more sense when they are placed diagonally in this way. Reduce the spacing around the labels by setting inner sep=0mm. Result: Code: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[% xmin=...

13

There are different ways of getting rid of that big empty space: Decrease the overall width of the plot, moving the groups of bars closer together. You can do this by specifying a unit vector for the x axis. If you add more data, the plot will grow automatically. Keep the overall width of the plot, but move the groups of bars closer together. You can do ...

11

Here is a somewhat roundabout way of achieving this. First add \coordinates at (Plain,3.43) and (Plain, 10.857), and in the lower corners with the rel axis cs coordinate system, then draw lines using these coordinate as reference. Legend entries are added with \addlegendimage. Note that units should not generally be written in italics, so a change there is ...

11

You can define where the "drawing origin" for logarithmic plots should be by setting log origin to either 0 or infty. If you set it to 0, which is the default, bar plots, comb plots and filled area plots will start from log(1)=0, so in this case the top of the plot. If you set it to infty, the plots will start from the bottom edge of the plot area, which is ...

11

You can make the value of the y coordinate available using the key visualization depends on=y \as \rawy (where \rawy is a macro name you choose). Then you can shift the nodes using shift={(axis direction cs:0,-\rawy)}. Note that you'll have to use axis direction cs because the coordinate system is shifted and scaled at the time when the nodes are placed. \...

11

Example using TikZ: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{url} \DeclareUrlCommand\function{\urlstyle{sf}} \usepackage{xcolor} \usepackage{tikz} \usepackage{booktabs} \usepackage{array} \usepackage{multirow} \usepackage{siunitx} \definecolor{chart Idle}{gray}{.6} \definecolor{chart Poor}{RGB}{242,28,28} \...

10

You can adapt the method from Center nodes near coords in a stacked ybar plot to use nodes near coords for the labels: \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \begin{document} \makeatletter \pgfplotsset{ calculate offset/.code={ \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed} \pgfmathsetmacro\testmacro{(\...

10

nodes near coords alone, without any further customization, results in the desired nodes on top of the bars. This has the disadvantage that your legend description are no longer a standard nodes near coords instruction. The way that pgfplots handles such a case would be to use legend entries, perhaps as in the following example: \documentclass{article} \...

10

The error bars aren't aligned with the bars because you're using the ybar interval plot style. I guess this would count as a missing feature, but in your case, you shouldn't actually be using ybar interval anyway, but simply ybar, since you're not trying to plot bars with different data dependent widths. To get a decent looking plot, you can try the ...

9

Whit pgfplots you can use something like this (not so automatized but still a solution) \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ name=like, scale only axis, xbar, xmin=0, xmax=40, %xbar=2pt, xlabel={likes}, width=5cm, height= 3cm, ytick={1,2,3,4,5}, yticklabels={sa,safda,afa,afa,af}, y tick label ...

9

To get a fixed distance between the centers of the bars, set x=<distance>. To set the width of the bars, set bar width=<distance>. To get a fixed amount of space between the first bar and the left edge of the plot, and between the last bar and the right edge of the plot, set enlarge x limits={abs=<distance>}. To label the bars, set nodes ...

9

you can use ybar=... to shift the bars apart. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ ybar=.5cm, ymin=50, ymax=120, height=5cm, width=7cm, xticklabels={enTwitter, +enNewswire}, ylabel=Accuracies (test set), enlarge ...

9

Try that: \documentclass{article} \usepackage{tikz,pgfplots,pgfplotstable} \begin{document} \pgfplotstableread{ % data Label Adequacy Sustainability Integrity Austria 21.87797 5.566584 24.85545 Brazil 20.93009 7.937881 24.33203 Chile 20.41148 21.126529 27.56199 Australia 26.83072 23.823827 28.94545 }\testdata \begin{...

8

You can adapt the solution from How can I add a zero line to a plot? to add the red line: \draw [red] ({rel axis cs:0,0}|-{axis cs:May '12,98}) -- ({rel axis cs:1,0}|-{axis cs:May '12,98}) node [pos=0.33, above] {KPI}; will draw a red line across the whole plot width with a label at one third of the length. Note that the x coordinate May '12 isn't actually ...

8

You can adapt the approach from Is it possible to change the color of a single bar when the bar plot is based on symbolic values? for colouring a single bar in a different colour. I'm not sure what the best approach is for the single long label (what is PP?). What I did here is just rotate the long label, while leaving the others unrotated. For adding the ...

8

In pgfplots you can always access the coordinates of the plot by means of axis cs; in this case, for example, you want to place a label with a number above (axis cs:A,6898.965904) plus the value of the error bar (this is something required otherwise your label will be located inside the error bar). To place a label it is possible to exploit the usual TikZ ...

8

You should do two things: Remove the xtick option Give an explicit data max of 14. The trick is to think of the thirteen bins not as the numbers 1, 2, ..., 13, but as the half-open intervals [1,2), [2,3), ..., [13,14). That's why the data max needs to be 14, not 13. Result: Amended code: \documentclass{article} \usepackage{pgfplots} \usepackage{...

8

You can scale all the tick labels by a common factor using scaled y ticks=base 10:-6 (dividing by 10^6). To switch off the scaling label, set ytick scale label code/.code={}. To add the word million after each label, set yticklabel={\pgfmathprintnumber{\tick} million}: \documentclass{article} \usepackage{pgfplots} \begin{document} \pgfplotsset{compat=1.9} \...

Only top voted, non community-wiki answers of a minimum length are eligible