Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have the pictured Histogram. It was generated by the following lines:

H = ExampleData[{"NetworkGraph", "HighEnergyTheoryCollaborations"}]
Histograms`Histogram[Length /@ ConnectedComponents[H], Histograms`HistogramRange -> {0, 25}, AspectRatio -> 2, BaseStyle -> 10]

enter image description here

I cut the x-axis at 25 because there is only one y(x)>0, x>25: x=5835. A better solution would be to cut x at 25, then continue x at 5834 and end it again at 5836. How can I achieve this?

share|improve this question
    
closely related: 8241 –  Kuba May 6 at 18:23
    
How can the bin width be changed? –  sdkbj May 6 at 18:42
    
some user who deleted its post suggested this Histogram[Select[Length /@ ConnectedComponents[H], # < 1000 &], PlotRange -> {{0, 50}, All}] which gives a plot stopping at 50. User said it may be because bin width is autoset. How can I set bin width? –  sdkbj May 6 at 19:04
    
@Kuba I can't find by googling "dx histogram mathematica" or "dx mathematica". sure you spelled right? got another keyword for me? –  sdkbj May 6 at 19:11
    
Details and Options section of Histogram you can find help about the function by pressing F1. –  Kuba May 6 at 19:13
add comment

1 Answer 1

Considering your working example on which I added 99 data of the maximum value:

g = ExampleData[{"NetworkGraph", "HighEnergyTheoryCollaborations"}];
data = (Length /@ ConnectedComponents[g]);
(* adding 99 value so it can be seen *)
data = Flatten@Append[data, ConstantArray[Max@data, 99]];

You can do the following, which is not very good looking in my opinion:

h1 = Histogram[Select[data, # < RankedMax[First /@ Tally@data, 2] &], 
  PlotRange -> {{0, RankedMax[First /@ Tally@data, 2]}, {0, Max[Last /@ Tally@data]}}, 
  Axes -> True, 
  AxesStyle -> {Arrowheads[{0, 0.075}], Automatic}, 
  AspectRatio -> GoldenRatio, ImageSize -> {230, 350}];

h2 = Histogram[Select[data, RankedMax[First /@ Tally@data, 2] < # <= Max@data &], {1}, 
  PlotRange -> {{Max@data - 2, Max@data + 2}, {0, Max[Last /@ Tally@data]}}, 
  Axes -> {True, False}, 
  AspectRatio -> GoldenRatio*6, Ticks -> {{Max@data}}, 
  ImageSize -> {230/6, 350}];

Grid[{{h1, h2}}, Spacings -> {-1.1, 1}]

enter image description here

I don't like:

  • The big arrow. That's all I could come up with that looked correct in my eyes, but it's not good looking.
  • The fact that everything is user defined (playing with AspectRatio, ImageSize or Ticks). There should be way to adjust the width of the last box automatically.

With the same data you can also do the following that I find better looking:

h3 = Histogram[Select[data, # < RankedMax[First /@ Tally@data, 2] &], 
  PlotRange -> {{1, RankedMax[First /@ Tally@data, 2]}, {0, Max[Last /@ Tally@data]}}, 
  AspectRatio -> GoldenRatio, Frame -> {True, True, True, True}, 
  FrameTicks -> All, 
  FrameTicksStyle -> {{Blue, Opacity@0}, {Blue, Opacity@0}}, 
  ImageSize -> {250, 350}];

h4 = Histogram[Select[data, RankedMax[First /@ Tally@data, 2] < # <= Max@data &], {1}, 
  PlotRange -> {{Max@data - RankedMax[First /@ Tally@data, 2] - 2, Max@data + 1}, {0, Max[Last /@ Tally@data]}}, 
  Axes -> None, 
  ChartStyle -> Directive[{Opacity@.5, Red}],
  AspectRatio -> GoldenRatio, Frame -> {True, True, True, True}, 
  FrameTicks -> All, 
  FrameTicksStyle -> {{Opacity@0, Red}, {Opacity@0, Red}}, 
  ImageSize -> {250, 350}];

Overlay[{h3, h4}]

enter image description here

share|improve this answer
    
Nice idea with this new one :) –  Kuba May 7 at 10:40
    
Thanks! The new one is not as sensitive as the first one at least, but I still don't really like it, it wouldn't work on every set of data. –  Öskå May 7 at 10:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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