Search code examples
excelgraphchartsoriginlab

Creating a histogram with numerical x-axis in excel


I would like to create a bar-chart (or a histogram?) with vertical bars and a numerical x-axis , but I do not know how/where to start. I have MS-Excel and Origin-plot available with me. My intended chart would look like this:

link for the chart


Solution

  • You can more or less get what you want by adding and styling error bars appropriately to a scatter plot. The error bar is a simple way to force Excel to draw a line under/over the point.

    Chart with data and error bars

    chart with error bars

    Couple steps

    1. Make an XY scatter chart
    2. Add the error bars and delete the horizontal ones that come up
    3. Set the negative error bar for the points to be equal to the same value that is being plotted
    4. Set the positive error bar to 0 so it does not show
    5. Change the formatting on the error bar to be thicker
    6. Possible hide the initial dot shown so that it is bar only

    You could take these steps and codify them with some VBA to prevent the tedious nature of doing this multiple times. Setting error bars is one of the worst activities to have to do continually.

    I believe you should also be able to get your desired colors by adding multiple series. Possibly all the more reason to do this with VBA.