3
$\begingroup$

I have a bar graph that I'm plotting. Some of the values are very large when compared to others. I want to put more focus on the smaller values, while still showing the larger elements.

The reason I want to do this is so that the resulting graph won't be unwieldy.

If I was drawing this by hand, I'd 'cut' the long bars and have a double-tilde in the middle of the elementgraph example

So my question is either:

  1. Can this be done in Mathematica?
  2. If not, can anyone think of a better way of keeping the dimensions of my graph small, while still containing enough detail to show the smaller values?
$\endgroup$
  • $\begingroup$ try Log your data. $\endgroup$ – Algohi Oct 10 '14 at 23:12
2
$\begingroup$
data = {50, 715, 579, 5, 96, 295, 1100, 7, 117, 17, 22, 8, 7, 561};

Framed@BarChart[data,
  ChartElementFunction -> "GradientScaleRectangle",
  ChartLabels -> {Placed[data, Above]},
  GridLines -> Automatic,
  ImageSize -> 500,
  Method -> {"GridLinesInFront" -> True},
  ScalingFunctions -> "Log"]

enter image description here

data = {50, 715, 579, 12, 96, 295, 1100, 430, 117, 17, 22, 8, 7, 561};

Framed@BarChart[data,
  BarOrigin -> Left,
  BarSpacing -> 0.3,
  ChartElementFunction ->
   ChartElementDataFunction["SegmentScaleRectangle", "Segments" -> 6, 
    "ColorScheme" -> "BeachColors"],
  ChartLabels -> {Placed[data, Right]},
  ImageSize -> 500,
  PlotTheme -> "Marketing",
  ScalingFunctions -> "Log"]

enter image description here

$\endgroup$
  • $\begingroup$ ScalingFunctions -> "Log" is exactly what I needed. It prevents me from Loging my data in advance which is what I was kind of trying to avoid $\endgroup$ – Arnon Oct 11 '14 at 10:32
3
$\begingroup$

This is a rough work around. I am sure someone will come up with better idea.

 data = RandomSample[
       Join[RandomInteger[1000, 5], RandomInteger[10, 10]], 15];
    BarChart[data]
    Show[ListLogPlot[data, PlotStyle -> PointSize[0.0]], 
     BarChart[Log[data]]]

enter image description here

$\endgroup$
  • $\begingroup$ That is a nice workaround indeed, but I think @eldo 's solution is a bit more straightforward for my use! $\endgroup$ – Arnon Oct 11 '14 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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