How to add mean/median points to horizontal bar chart with VBA?

Kelvin Stott

Active Member
Joined
Oct 26, 2010
Messages
338
Hello,

I have managed to write VBA code to create horizontal boxplots from scratch, based on stacked bar charts as described here: Excel Box and Whisker Diagrams (Box Plots) | Peltier Tech Blog | Excel Charts

However, I am now struggling to add points to this chart by adding a new dataseries with a different chart type, again using only VBA code. I have managed to plot the points correctly along the horizontal value axis with the xlXYScatter chart type, but I can't plot them correctly along the vertical category axis so that they lign up with the horizontal bars:

https://docs.google.com/file/d/0B4rFQKgfCtswRUY0MXlpQnJMa1k/edit?usp=sharing

So how can I get the points to lign up with the horizontal bars along the vertical axis?

Am I using the right chart type (xlXYScatter), and how should I set .Values and .XValues for my data series? Do I need to configure .ChartGroups(2) in some way?

Thanks for any help!

Best regards,
Kelvin
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Perfect, thank you. I see now that I have to set the values of secondary vertical axis (.Values) to N - 0.5, where N is the point number, and then invert/reverse the axis. I don't know why I missed that in Peltier's boxplot article which I cited above.

Tested and working perfectly fine, thanks!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top