Bars! Bars! Bars!
Make bar charts rammed full of extra features:
- in full technicolor, with a unique colour for every bar if that's what you're into
- showing errors on the values using errorbars, with many styles available
- with statistical significance of each bar indicated with stars above them
- with statistical significance of comparisons between pairs of bars shown with lines between the pairs and stars above them
- and all this in either horizontal or vertical orientations
Have no fear. Superbar is here!
And that's not all! It comes with a free copy of SUPERERR, which you can use to plot error bars not on bar charts. Plot errors in both X and Y with lots of style options for capped, uncapped, one-directional, symmetric, asymmetric errorbars. It can do everything you want, just as long as what you want is to plot errorbars on a set of linear-linear axes!
If you want to help make SUPERBAR even more super, you can report bugs and suggest new features on GitHub:
Tested in R2011a (Windows) and R2016a (Windows & Ubuntu).
Scott Lowe (2020). superbar (https://www.github.com/scottclowe/superbar), GitHub. Retrieved .
just made a function called barmod--wanted to make sure that I wasn't reinventing the wheel, so I took some time to demo Scott Lowe's work here. Barmod is more for positioning and placement. If the functionality is useful to you, here's a link: https://www.mathworks.com/matlabcentral/fileexchange/75853-barmod
Great!! Thank a lot!!!
Powerful and robust.
This function just saved my life. Being able to put error bars as well as the significance level stars above, is ideal. This is what people want for a publishable figure. Also, as the comments suggested, the legend colors can be fixed by doing ax(1,:) as a parameter. The customizability for this function is incredible.
i found a workable solution. somehow the list of bar handles from superbar is transposed, such that legend operates along the first column of handles when what one wants for group-corresponding legend colors would be operating along the first row. set ax = superbar(...); when setting legend, use the first row of ax - that is, ax(1,:) - to set the subset for legend.
ax = superbar(...);
hi scott. this is great. my only issue is the one mentioned below: the legend colors do not come out correctly. for me, they typically come out all as the same color as the first bar group.
is there a workaround this issue, or is it a known bug?
Almost perfect. Only two things lacking. 1) ability to rename x-axis of grouped bars (i.e. Time 1, Time 2, Time 3) and 2) the legend colors don't match the bar colors of grouped bars.
Regarding the comment made inside ‘superbar’ by the author: “If you see boxes showing a rectangle with a cross through them instead of stars … “
I encountered this issue, but it is easily resolved. Simply set ‘string’ and ‘interpreter’ properties of HPT handles returned by ‘superbar’ to ‘\ast’ and ‘tex’, respectively.
This is one of the best plotting utilities on FEX. Thanks for sharing!
Hi Scott, how to plot upward errorbars for positive means, and downward errorbars for negative means at the same time?
Thanks for this - I'm finding it really useful!
One question - I'm making a grouped bar plot (ie two different bars for each value on the x axis), and I want the colors to be different for each group. I can't seem to figure out how to do this - no matter how I set the color matrix up with 'BarFaceColor,' it seems that the two bars for each x axis value are always the same color rather than a unique color for each group, as I want them to be. Can anyone help? Thanks!
Thanks Scott for this great function! The lines for pairwise comparison don't work when using asymmetric error bars. I've added the following line at the beginning of the function 'plot_p_values_pairs', which does the trick:
if size(E,2)==2 ; E=E(:,2); end
Aaaah this is exactly what I needed. It's so pretty and easy!
I've got one question though: I have plots where all values are negative - is there a way to make the main lines start at the zero point instead of the top of the highest bar? Or to put them below the bars? So that they're not overlapping with the bars themselves?
This should replace the current 'bar' function supplied by Matlab.
Hi Michael, I've added a 'BarLineWidth' input to SUPERBAR now, so you can change the width of the bar edges more easily, and the default width is wider than it used to be.
Thanks for your feedback!
Hi, Michael! I'm glad to hear you found superbar easy to set up and use, especially since the documentation isn't finished yet! It is currently not possible to pass arbitrary inputs to bar via superbar (though I do intend to add this at some point in the future). For the time being, you have to change the properties of the bars created by superbar using the first set of handles it returns. For example,
`h = superbar(Y, 'BarEdgeColor', 'k'); set(h, 'LineWidth', 2);`. Hope that helps!
Great tool! Had it up and integrated in couple minutes. One question: is there an easy way to control the line-thickness of bars?
Excellent! So many customizations. I've been waiting a long time for someone to do all this work for me.
- PStarLatex option allows changing whether significance text is rendered using the LaTeX interpreter, with the default now as `'off'`.
- Support for older version of inputParser in R2007a-R2013a with `addParamValue` instead of `addParameter` method.
Added support for cell array colour inputs.
Added README, tutorial, logo.
Add unit tests for SUPERBAR.
When there is no source separation, offset line starts.
Change output shapes of HB, HPT, HPL, HPB to match the shape of Y.
- Avoid axes input to text and line fns, supporting <R2016a (tested in R2015b)
Change default orientation of star text for horizontal bars; now normal for single p-values and sideways for pair-wise p-values.
Show pairwise comparison lines on horizontally oriented plots.
Inspired by: HERRORBAR, errorbarxy, Enhancement to errorbar() plot, xyerrorbar, BarsWithError, errorbarlog.m, barerrorbar(varargin), plot errorbars on both axes, errorbarlogx.m, barweb (BARgraph With Error Bars), errorbarlogy, errorbar_x, ploterr, Adjust error bar width, bar3color(varargin), Bar- and candle style graph for stocks, Enhanced Errorbar Function, Bar with errorbars, raacampbell/shadedErrorBar, Create Healthy Looking Error Bars, set errorbar width and thickness, Coloured bar chart, barwitherr(errors,varargin), Faded bar chart, 3D Bar Plot with Error Bars, bar_setFaceAlpha, Update error bar widths automatically on figure resize, xerrorbar - Just like errorbar, but for uncertainty in x., MATLAB Plot Gallery - Vertical Bar Plot, MATLAB Plot Gallery - Stacked Bar Chart, MATLAB Plot Gallery - Horizontal Bar Plot, MATLAB Plot Gallery - Errorbar Plot, Plot data with error bars on both x and y axes, hbarerrorbar, pierremegevand/errorbar_groups, errbar, terrorbar.m: Error bars with controlled widths post-R2014b, K_shadedErrorBar(), errorbarxy, orxy(x,y,limx,limy,errx,erry,col,factor), plotyyyerrxy, linebar