开发者

GridLine on top of a Bar Chart in Mathematica

Is it possible to get a GridLine over a BartChart ? Gridlines draw it under and Mesh does not seem to work with BarChart.

BarChart[{Range[10], Range[10]}, 
         ChartLayout -> "Stacked", 
         GridLines -&g开发者_如何学Got; {None, {4}}, 
         GridLinesStyle -> Directive[Orange, Thick]]

GridLine on top of a Bar Chart in Mathematica


This can be done via a method option:

BarChart[{Range[10], Range[10]}, ChartLayout -> "Stacked", 
 GridLines -> {None, {4}}, GridLinesStyle -> Directive[Orange, Thick],
  Method -> {"GridLinesInFront" -> True}]

GridLine on top of a Bar Chart in Mathematica

(this should work for any graphic.)


Your other option would be to draw the gridline explicitly with Epilog. This would be the solution if you wanted some gridlines (e.g. vertical ones) behind and some in front. I have added some other options in case you don't actually want the gridline to bleed over the axes.

BarChart[{Range[10], Range[10]}, ChartLayout -> "Stacked", 
 Epilog -> {Orange, Thick, Line[{{0, 4}, {3, 4}}]}, 
 PlotRangeClipping -> True, PlotRangePadding -> 0]

GridLine on top of a Bar Chart in Mathematica

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜