I tried to replicate a bar graph for the first time and have two problems with the x-axis. Could someone help me?  This is the graph i would like to replicate.  1. How do I get a group of bars next to each other separated from another group? And 2. how to center the label for each group?  Here is my MWE and a screenshot.  \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ xbar, xlabel = $\beta$, width=\linewidth, bar width=30pt, xtick={}, xticklabels={neutral, anger}, axis lines*=left, clip=true, ymin=0, ymax=1, ylabel={annual discountfactor}, legend style={at={(1,1)},font=\tiny} ]  \addplot[ fill=blue, draw=black, ybar, point meta=y, error bars/.cd,     y dir=both,     y explicit ]  table [y error=error] { x            y           error    1   0.0401    0.0177  1.8   0.0252    0.0048 }; \addlegendentry{$\delta_{1}$} \end{axis} \end{tikzpicture} \end{document}
120836
I am trying to create a grouped bar chart with pgfplots, like this one:    but I can't put the values over the bars, like this one:    My code is:  \documentclass{article} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=newest} \usepackage{caption} \usepackage{polyglossia} \setdefaultlanguage{portuges}  \begin{document}  \begin{figure}[h] \makeatletter \pgfplotsset{     calculate offset/.code={         \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}         \pgfmathsetmacro\testmacro{(\pgfplotspointmeta *10^\pgfplots@data@scale@trafo@EXPONENT@y)*\pgfplots@y@veclength)}         \pgfkeys{/pgf/fpu=false}     },     every node near coord/.style={         /pgfplots/calculate offset,         yshift=-\testmacro     } } %0 - aramente   1 - Às vezes   2 - Quase sempre   4 - Sempre \pgfplotstableread{   %2013-2014    %2012-2013  %2011-2012 0 32        35      20 1 28        45      23 2 30        24      25 3 10        68      70 }\dataset \begin{tikzpicture} \begin{axis}[ybar,         width=12cm,         height=8cm,         ymin=0,         ymax=100,                 ylabel={Percentagem},         xtick=data,         xticklabels = {             Raramente,             Às vezes,             Quase sempre,             Sempre             %Category 5,             %Category 6         },         xticklabel style={yshift=-10ex},         major x tick style = {opacity=0},         minor x tick num = 1,         minor tick length=2ex,         every node near coord/.append style={                 anchor=east,                 rotate=90         }         ] \addplot[draw=black,fill=blue!20, nodes near coords=2013-2014] table[x index=0,y index=1] \dataset; %ano de 2013-2014 \addplot[draw=black,fill=blue!40, nodes near coords=2012-2013] table[x index=0,y index=2] \dataset; %ano de 2012-2013 \addplot[draw=black,fill=blue!60, nodes near coords=2011-2012] table[x index=0,y index=3] \dataset; %ano de 2011-2012 \end{axis} \end{tikzpicture} \captionsetup{justification=centerlast, margin=10ex, labelfont=bf, textfont=it, format=plain, labelformat=default, labelsep=endash, font=small, name=Gráfico\,} \caption{Em sua casa é costume desligar os equipamentos no controlo remoto, deixando-os em standby (modo de “espera”)?}\label{Questao01}  \end{figure}  \end{document}
29158
I am using PGFplot to make a barchart. There are 4 entries in my csv file and unfortunately I have only 3 bars in my figure.   my LaTeX code:  \begin{figure}     \centering     \begin{tikzpicture}          \begin{axis}[             x tick label style={/pgf/number format/1000 sep=},                 xlabel=Sequence,             ylabel=Heigth,                 ymin=0.7,             enlargelimits=0.05,             legend style={at={(0.5,-0.15)},                 anchor=north,legend columns=-1},             ybar interval=0.7,             width=\textwidth,             ]             \addplot table [col sep=comma,trim cells=true,y=height] {numericaltests/data/test.csv};              \addplot[red,sharp plot,update limits=false]                 coordinates {(-1,1.00) (34,1.00)}                 node[above] at (axis cs:15,1.00) {};             \legend{Ca2Fe2As2}         \end{axis}     \end{tikzpicture}     \caption{Sequence}     \label{fig:sequenceHeight} \end{figure}   my test.csv file:  sequence,height 1,2.0 2,1.5 3,1.8 4,2.4   Barchart:
38776
I'm making a ybar graph (vertical bars) where the y axis maximum reaches 150+, but a lot of values are 0's. I would like the final graph would not show a minimum bar in this 0 values, since we this values it can easily be mistaken with a low value (1,2, etc).  My code:   \documentclass{article}  % ---------------------------------- tikz  \usepackage{pgfplots}          % to print charts \pgfplotsset{compat=1.8}  \begin{document}  \begin{figure}   \centering   \begin{tikzpicture}     \begin{axis} [       % general       ybar,       scale only axis,       height=0.5\textwidth,       width=1.2\textwidth,       ylabel={# Dots},       nodes near coords,       xlabel={Variation},       xticklabel style={         rotate=90,         anchor=east,       },       enlarge x limits={abs value={3}},       ]       \addplot table [         x=grade,         y=value,       ] { grade   value -11 0 -10 0 -9  0 -8  0 -7  0 -6  0 -5  3 -4  1 -3  2 -2  15 -1  11 0   179 1   8 2   1 3   0 4   1 5   2 6   0 7   0 8   0 9   0 10  0 11  0       };     \end{axis}   \end{tikzpicture} \end{figure} \end{document}   My graph:
13797
Is it possible to tell pgfplots to put tick labels between the tick marks instead of at the tick marks?  MWE:  \documentclass[margin=5pt]{standalone}  \usepackage{tikz} \usepackage{pgfplots}  \begin{document}      \begin{tikzpicture}          \begin{axis}[             width=5in,             height=3in,             axis lines=middle,             scaled ticks=false,             xtick=\empty,             xmin=0,             xmax=3,             extra x ticks={0,1,2,3},             extra x tick labels={low,high,med},         ]          \addplot [mark=*,draw] coordinates {(0.5,2) (1.5,4) (2.5,3)};          \end{axis}     \end{tikzpicture}  \end{document}   Result:    I can do it manually by adding  xticklabel style = {xshift=1.9cm,align=center},     but this seems unsatisfying, unreliable, and requires too much trial and error.
44109
I am drawing some graphs with tangents. I calculated the tangent should be centered at x=57/27 which is approximately x=2.11. I'm currently using the pos and sloped keys for nodes to draw tangents, but I'm not happy about the result; the tangents don't really align.   I think this is because the pos key calculates the actual length of the graph while the graphs don't have the same length.  I'm sure I can somehow let LaTeX do the calculations for me so as to align the slopes vertically at an x value of my choice. But how?  PS: The below document requires a working installation of gnuplot to compile.    \documentclass{standalone}   \usepackage{pgfplots} \pgfplotsset{compat=1.10} \usetikzlibrary{arrows, decorations.markings,intersections}  \makeatletter \tikzset{     nomorepostaction/.code=\makeatletter\let\tikz@postactions\pgfutil@empty,      my axis/.style={         postaction={             decoration={                 markings,                 mark=at position 1 with {                     \arrow[ultra thick]{latex}                 }             },             decorate,             nomorepostaction         },         thin,         -,         every path/.append style=my axis     } } \makeatother  \definecolor{headtitle}{RGB}{167,63,63}  \begin{document} \begin{tikzpicture}   \begin{axis}[%       axis line style={my axis},       xlabel = $U_A$,       ylabel = $S$,       xmin = 0, xmax = 3.25,       ymin = 0,       xtick={1,1.5},       xticklabels={$U_{B,\mathrm{initial}}$,$U_{A,\mathrm{initial}}$},       xticklabel style={             inner sep=0pt,             anchor=north east,             rotate=35         },       ytick=\empty,       height=.66\linewidth, width=\linewidth-4.5\tabcolsep,       axis lines*=left,       every axis y label/.style={at=(current axis.above origin),anchor=east},       every axis x label/.style={at=(current axis.right of origin),anchor=west}]%     \addplot+[mark={},draw=headtitle] gnuplot[raw gnuplot] {%       set samples 51;       plot [0:3] log(3*(3-x)+1);       } node[sloped,above,pos=.63333,       minimum height=1cm,minimum width=1cm] (SB) {} node[pos=0.6,pin=45:{\color{black}{$S_B$}}] {};      \addplot+[mark={},draw=headtitle] gnuplot[raw gnuplot] {%       set samples 51;       plot [0:3] log(9*x^2+6*x+1);       } node[sloped,above,pos=.83333,       minimum height=1cm,minimum width=1cm] (SA) {} node[pos=0.25,pin=-15:{\color{black}{$S_A$}}] {};       \addplot+[mark={},draw=headtitle] gnuplot[raw gnuplot] {%       set samples 51;       plot [0:3] log(9*x^2+6*x+1)+log(3*(3-x)+1);       } node[sloped,above,pos=.775,       minimum height=1cm,minimum width=1cm] (St) {} node[pos=0.525,pin=165:{\color{black}{$S_\mathrm{total}$}}] {};      \path (SB.south east) edge[headtitle,very thick] node {} (SB.south west);      \path (SA.south east) edge[headtitle,very thick] node {} (SA.south west);      \path (St.south east) edge[headtitle,very thick] node {} (St.south west);   \end{axis}% \end{tikzpicture}% \end{document}
25451
I am trying to use PGFPlots to display a large amount of bars, and I run into the problem that it cuts off the last of them.  MWE:  \documentclass[crop,tikz]{standalone}  \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=1.13}  \begin{document}  \pgfplotstableread{ row label runtime 0 1 5264 1 2 2971 2 4 1866 3 8 1384 4 16 1205 5 32 1144 6 64 1109 7 128 1095 8 256 1108 9 512 1178 10 1024 1335 11 2048 1667 12 4096 1588 13 8192 2843 14 16384 5541 15 32768 10985 16 65536 21873 17 131072 43687 18 262144 87064 19 524288 174119 }\mytable   \begin{tikzpicture}   \begin{axis}[         ylabel={runtime (${\mu}s$)},         xticklabels from table={\mytable}{label},         xtick=data,         ymin=0,         ymax=10000,         ybar,         xticklabel style={           anchor=north west,           align=left,           rotate=-45,           font=\tiny,           inner sep=1pt,         }, ] \addplot+ [] table [y=runtime, x expr=\coordindex] {\mytable}; \end{axis} \end{tikzpicture}  \end{document}   Result:    By adding the following to the axis options, I can make all the bars fit. But I need to manually adjust bar width (and xmax)  xmin=-1, xmax=20, bar width=7pt,     Is there a way to handle many bars in a barplot automatically?
59834
I've just started to play with pgfplot. I'm trying to prepare a plot like to following   \begin{figure}[h] \centering \begin{tikzpicture} \begin{axis}[minor tick num=1,  axis x line=middle, axis y line=middle, xlabel=$k$, ylabel=$\omega$, ymin=0,xmin=-2,ymax=60] \addplot[blue,domain=0:5, line width=1.5pt] {x^2+25}; \addplot[orange,domain=0:5,line width=1pt]{3*x+22.75}; \addplot[cyan,domain=0:1.5, line width=1pt,dashed]{18.166*x}; \node[coordinate,pin=right:{$v_{\phi}=\frac{\omega}{k}$}]     at (axis cs:1,17) {}; \node[coordinate,pin=right:{$v_{g}=\frac{d\omega}{dk}$}]     at (axis cs:2.5,30) {}; \node[coordinate,pin=left:{dispersion relation}]     at (axis cs:4.5,47) {}; \end{axis} \end{tikzpicture} \caption{Wave dispersion relation with phase and group velocity} \label{fig:2} \end{figure}   What I would like to do is dropping the x-y tick labels so that we just maintaing the x-y title. How can I obtain it?
98688
I've been trying to figure out how to change the chart from scientific notation to just show the 5 digit numbers. I've tried scale and scale ticks with not success.  How can I change the y-axis and data values to show the decimals not in scientific notation?  \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={at={(0.5,-0.20)}, % -.20 y-axis     anchor=north,legend columns=-1},     ylabel={Densities},     nodes near coords,     every node near coord/.append style={ anchor=mid west, rotate=90},     symbolic x coords={Class1,Class3,Class5,Class7,Class9,Class11,Class13,Class15,Class17,Class19,Class21,Class23},     xtick=data,     xticklabel style={ inner sep=0pt, anchor=north east, rotate=70 },     nodes near coords align={vertical}, ] \addplot coordinates { (Class1,0.0968) (Class3,0.0887) (Class5,0.1452) (Class7,0.0726)     (Class9,0.0403) (Class11,0.0081) (Class13,0.0161) (Class15,0.0000)     (Class17,0.0161) (Class19,0.0081) (Class21,0.0000) (Class23,0.0081) }; \end{axis} \end{tikzpicture}
5905
can anybody help me to draw this minimal example of an xy axis? I couldn't find anything similar on the forum.  The axis should be black but the grid behind it a shade o gray, dashed. It would be great if the axis were a little bit thicker than the grid also.
8659
I made a plot but it's not at all what I want. There are two things I'm having trouble with: 1.) The bars should be at the bottom, but there's a space between them and the x-axis. 2.) E1/E4, E2/E5 and E3/E6 should have the same color.  Here's a picture of how it is and how I want it below:   And here's my code:  \documentclass{standalone} \usepackage{pgfplots,pgfplotstable} \begin{document} \begin{tikzpicture} \begin{axis}[ symbolic x coords={E1, E4 (dyn.), E2, E5 (dyn.), E3, E6 (dyn.)}, xtick=data, width=\linewidth, height=6cm ] \addplot[ybar,fill=blue, bar width = 1cm] coordinates {     (E1,   8)     (E2,  15)     (E3,   50)     (E4 (dyn.), 4)     (E5 (dyn.), 17)     (E6 (dyn.), 40)  }; \end{axis} \end{tikzpicture} \end{document}   I hope you can help me. Thanks.
45632
For the bar chart proposed, I would like to use different color for each single bar. How can I  do this?  \documentclass{article} \usepackage{pgfplots}  \begin{document}  \begin{tikzpicture}   \begin{axis}[     title=Title,         xbar,         xmajorgrids = true,         bar width=6mm,          width=12cm, height=5.5cm,          enlarge y limits=0.2,         xlabel={\#number},         symbolic y coords={A,B,C,D},         ytick=data,         nodes near coords, nodes near coords align={horizontal},   ]    \addplot coordinates {(1,A) (7,B) (5,C)(2,D)}; \end{axis} \end{tikzpicture}  \end{document}
94925
I have two questions regarding the pgfplots package. I have attached the source code I worked on. There are two features I am not able to realize:   I would like to put the total value (sum of the whole stacked bar) on top of the bar, rotated by 90°. For me, it was only possible yet to get the value of each part of the stacked bar by using the nodes near coords command. Additionally, the percentage of each part of the stacked bar as relative to the whole stacked bar should be displayed in the bar, also rotated by 90° (addition equals 100%)   If it is somehow possible, percentages should have only one significant digit, and those below 5% should not be displayed in the bar. I know this is a pretty complex example, but maybe there is one who can solve it.  \documentclass{article}  \usepackage{pgfplots,pgfplotstable}   \usetikzlibrary{pgfplots.groupplots}    \pgfplotsset{compat=1.8}   \pgfplotstableread{  Criterion  ddd     ccc     vvv   (0)    700         750         750   (a)    700         750         750   (b)        1200        750         750       (c)    33      345     345  (d)    34      333     345  (e)    234     344     344   }\Rob   \pgfplotstableread{  Criterion  ddd     ccc     vvv   0      70          75          75    a      70          75          75    b          120         75      75        c      3       34      34  d      3       33      34  e      23      34      34  }\Gab   \begin{document}  \begin{tikzpicture} \begin{groupplot}[group style= {     columns=2,xlabels at=edge bottom,     ylabels at=edge left,     horizontal sep=1cm,group name=plots, }, ymin=0, enlarge x limits={abs=.5}, enlarge y limits={upper,value=0.4},  ylabel=Mon, ylabel style={text height=0.02\textwidth,inner ysep=0pt},  ybar,ybar stacked, major x tick style = transparent,  /pgf/bar shift=0pt, /pgf/bar width=9pt, x tick label style={text height=2ex},    xlabel style={yshift=-2ex},  xticklabels from table={\Rob}{Criterion},  xtick=data,legend columns=-1, legend style={draw=none, /tikz/every even column/.append   style={column sep=5pt}}]  \nextgroupplot[xlabel=Rob, xlabel shift = -7.5cm, legend to name=grouplegend] \pgfplotstableforeachcolumn\Rob\as\col{     \ifnum\pgfplotstablecol=0      \else       \edef\tmp{         \noexpand\addplot table [x expr=\noexpand\coordindex,y=\col] {\noexpand\Rob};         \noexpand\addlegendentry {\col}     }     \tmp     \fi }  \nextgroupplot[xlabel=Gab, xlabel shift = -7.5cm] \pgfplotstableforeachcolumn\Gab\as\col{     \ifnum\pgfplotstablecol=0      \else     \edef\tmp{         \noexpand\addplot table [x expr=\noexpand\coordindex,y=\col] {\noexpand\Gab};     }     \tmp     \fi   }   \end{groupplot}  \draw[dashed] (plots c1r1.south west) -- ++(0,-1.5);   \draw[dashed] (plots c1r1.south east) -- ++(0,-1.5);  \draw[dashed] (plots c2r1.south west) -- ++(0,-1.5);  \draw[dashed] (plots c2r1.south east) -- ++(0,-1.5);  \node at (plots c1r1.south) [inner sep=0pt,anchor=north, yshift=-12ex]     {\ref{grouplegend}};  \end{tikzpicture}  \end{document}
20320
I have a groupplot of 5x3. Now I want to be able to 'overlap', so to speak, the ylabel over all the plots vica versa for the xlabel. This enables me namely to make the groupplot smaller.   Currently I have the following code: . Which gives me the output given below. Thus what I want is to be able to stretch the labels "Phase [*] Magnitude [dB]' over all the plots, as a 'general' ylabel. And 'Frequency [Hz]' for the xlabel.   How can I achieve this?   Currently I just setted the ylabel as {Phase [*] Magnitude [dB]\\Out2} and xlabel as {Frequency [Hz]}. And did some xshift on the ylabel such that the 'Out i' would align with each other. This looks nice now for a 5x3 but what if I have a 2x2 groupplot, I don't have a plot in the middle then.
97234
I'm trying to draw a relatively simple chart of a number line, and when one of the nodes is too close to the edge of the plot, it gets cut off.  The code:  \documentclass{article}  \usepackage{natbib} \usepackage{graphicx} \usepackage{pgfplots}  \begin{document}  \begin{tikzpicture} \begin{axis}[   width=\columnwidth,   axis y line=none,   axis lines=left,   axis line style={-},   xmin=0,   xmax=1,   ymin=0,   ymax=1,   xlabel=$\mu$,   scatter/classes={o={mark=*}},   restrict y to domain=0:1,   xtick={0,1} ] \draw[ultra thin] (axis cs:0, 0) -- (axis cs:0,.05); \draw[ultra thin] (axis cs:.4, 0) -- (axis cs:.4,.05); \node[coordinate,label=above:{$B$}] at (axis cs:0.0,0.05) {}; \node[coordinate,label=above:{$A$}] at (axis cs:0.4,0.05) {}; \node[coordinate,label=above:{$b$}] at (axis cs:0.2,0.02) {}; \node[coordinate,label=above:{$a$}] at (axis cs:0.7,0.02) {}; \end{axis}; \end{tikzpicture} \end{document}   The Result:    How do I get the B to fully render?
80718
With pgfplots, I am creating a simple coordinate plot with error bars like this:    \documentclass[crop,10pt]{standalone} \usepackage[english]{babel} \usepackage{pgfplots}      \begin{document}%         \setlength{\linewidth}{246pt}%              \begin{tikzpicture}             \begin{axis}[             width=\linewidth,             ytick pos = left,             xtick pos = left,             clip=false,             axis on top,             tick align = outside,             yticklabel style={%             /pgf/number format/fixed,             /pgf/number format/precision=1,             /pgf/number format/fixed zerofill         },             ytick scale label code/.code={},             xlabel={X},             ylabel={Y},     ]             \addplot[mark=*]             plot[             error bars/.cd,             y dir=both,             y fixed=0.0001     ]             coordinates{(1,0.0005) (1.1,0.0013) (5,0.0015)};             \end{axis}             \end{tikzpicture}     \end{document}   In the original plot I have a lot more points. I would now like the line and the markers (including the error bars) to have different colors to better distinguish the line from the error bars. Is that somehow possible? The only way I found so far is to plot the data just as a line in one color and then plot it again just as markers in another color. This works, but I guess there must be some better solution to this. Thanks for the support, John
53029
I am trying to plot a scatterplot with a fit line that I have already calculated, but I am having trouble getting them to line up and use the same scale. I tried doing it with  \begin{tikzpicture}[domain=0:8] \begin{axis}[xlabel={$\Delta x$ (m)}, ylabel={$Mg$ (N)}]     \draw[color=red, domain=0:1000] plot (\x,{0.0051026+10.372231*\x}) node[below right] {}; \addplot[scatter, only marks, scatter src=\thisrow{class},       error bars/.cd, y dir=both, x dir=both, y explicit, x explicit, error bar style={color=mapped color}]       table[x=x,y=y,x error=xerr,y error=yerr] { x      xerr      y        yerr     class 0.0047 0.0007071 0.054039 0.000098 0 0.0142 0.0007071 0.152651 0.000098 0 0.0237 0.0007071 0.252051 0.000098 0 0.0332 0.0007071 0.350466 0.000098 0 0.0525 0.0007071 0.548380 0.000098 0 0.0622 0.0007071 0.646893 0.000098 0 0.0720 0.0007071 0.746195 0.000098 0 0.0802 0.0007071 0.844709 0.000098 0 }; \end{axis} \end{tikzpicture}   but I am getting a plot that looks like    Can I make the fit line match up with the scatter plot with the type of plot I am using? If not, how can I make this work?
6831
Tufte advocates to "minimize the ink-to-data ratio" for charts. I am trying to style a multi data series bar chart, that can have a grid and axes as shown below (chart at the left is from the Economist and on the right my attempt).      Here is the code:  \documentclass[justified]{tufte-book} \usepackage{pgfplots,lipsum} \pgfplotsset{compat=newest} \begin{document} \section{Bar Charts}  \lipsum[1-2]\vfill   \begin{figure*}[htbp]   \fbox{  \begin{tikzpicture}   \centering   \begin{axis}[         ybar,           title={Cumulative Progress of Works},         height=8cm,         width=15.5cm,         bar width=0.4cm,         ymajorgrids, tick align=inside,         enlarge  y limits={value=.2,auto}, % see the upper          ymin=0,         ymax=100,         axis x line=bottom,          axis y line=right,         %enlarge x limits =e,         legend style={at={(0.5,-0.2)},         anchor=north,legend columns=-1},         ylabel={Percentage (\%)},         symbolic x coords={            Sep-11,Oct-11,Nov-11,Dec-11,            Jan-12,Feb-12,            Mar-12,           Apr-12},        xtick=data,        nodes near coords,        every node near coord/.append style={         anchor=mid west,         rotate=70       }     ]     \addplot coordinates {       (Sep-11,75.4064)       (Oct-11, 72.7961)        (Nov-11,94.4597)       (Dec-11,66.6786)        (Jan-12,67.5600)        (Feb-12,88.2339)       (Mar-12,78.6138)        (Apr-12,58.9129) };    \addplot coordinates {       (Sep-11,75.4064)       (Oct-11, 89.7961)        (Nov-11,94.4597)       (Dec-11,76.6786)        (Jan-12,77.5600)        (Feb-12,78.2339)       (Mar-12,88.6138)        (Apr-12,78.9129) };    \addplot coordinates {       (Sep-11,75.4064)       (Oct-11, 89.7961)        (Nov-11,94.4597)       (Dec-11,76.6786)        (Jan-12,77.5600)        (Feb-12,78.2339)       (Mar-12,88.6138)        (Apr-12,78.9129) };      \legend{First Fix,Second Fix,Third Fix}   \end{axis}   \end{tikzpicture} }  \caption{\protect\raggedright Cumulative progress for all MEP works. Notice the slower rate of production during the last three months.} \end{figure*}  \lipsum[1-3] \end{document}   I have moved the y-axis to the right, but cannot get rid of the axis line. The plot is also not fitting within the plot width, despite using \enlarge.   Edit  And thanks to Jake the ugly duckling has been transformed to the following, with minor variations to the code as suggested by Jake. I have only added a stronger color for one of the bars in order to highlight it: