I have made a box plot to show the spread of past paper results for my A2 exams so I can easily see which subject need more work!

BoxWhiskerChart[data, "Outliers", ChartLabels->{data[[All,1]]}, BarOrigin->Left, ImageSize->Medium, ChartStyle->Blue]

The above code gives me the following output:

enter image description here

Now, the average for an A is around 61 marks, is there a way to draw a line going from the bottom to top of the chart at the 61 mark limit. This could then give me a better indication of what sort of grade I'm hitting.


2 Answers 2


You can also use the options GridLines and Method -> {"GridLinesInFront" -> True}:

grades = RandomInteger[{30, RandomInteger[{50, 100}]}, {7, 10}];
gridline  = Median[Join @@ grades];
classes = {"Mathematics", "History", "English", "Chemistry", "Law", 
   "Physics", "Statistics"};

BoxWhiskerChart[grades, "Outliers", ChartLabels -> classes,
 BarOrigin -> Left, ChartStyle -> 10, ImageSize -> 500, 
 GridLines -> {{{gridline, Gray}}, None}, 
 Method -> {"GridLinesInFront" -> True}]

Mathematica graphics


After looking about online a bit more I found the Epilog option. To draw my lines I have added Epilog->{Directive[{Thick, Red, Dashed}], Line[{{61,0},{61,10}}]} to the end of the BoxWhiskerChart environment.

NB. The 10 in {60,10} is the height of the plot with respect to the bars. There are 9 bars plus half either side of the top two, hence 10.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.