TransWikia.com

Why are these two histograms plotting so differently?

Mathematica Asked by Jonathan Shock on February 5, 2021

I have two lists, which are pretty similar. They are given by:

list1=Flatten[Table[#[[1]], #[[2]]] & /@ {{1, 2},{2, 9},{3, 3},{4,73},{5, 38}}]
list2=Flatten[Table[#[[1]], #[[2]]] & /@ {{1, 2},{2, 10},{3, 8},{4,65},{5, 22}}]

ie. list1 is a list of 2 1’s, 9 2’s, 3 3’s, etc.

If I plot a histogram of them next to each other they come out like this:

{Histogram[list1],Histogram[list2]}

enter image description here

And I can’t figure out why the labelling is different. I would like to have all of my numbers in the centre of the column, so tried using the answer from this question. as so:

{Histogram[list1, 
  Ticks -> {{# + .5, #} & /@ HistogramList[list1][[1]], Automatic}], 
 Histogram[list2, 
  Ticks -> {{# + .5, #} & /@ HistogramList[list2][[1]], Automatic}]}

But that comes out like this:

enter image description here

Any idea what’s going on?

One Answer

enter image description here

This in Mac version 12.1.0.0 using the input provided.

Answered by PaulCommentary on February 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP