How to colour entire object based on its height I have a bunch eg 5,000 extruded objects (think columns) each of different height. All off these exist as a single object, ie they are grouped together rather than individual layer objects. I want to apply a colour ramp so that each of the individual columns are coloured based on their height value, rather than the entire group.

This doesn't mean that the colour ramp is applied against the z axis resulting in the object having a colour fade as is gets taller, but more like the entire coumn is coloured based on its maximum height, and therefore corresponding colour on the colour ramp.

The columns are "hex bins" of a 2km geographic area. Their individual height represents the urban density. See image attached.

Hope that makes sense. If you are able to post the script / specific setup for this then I would be grateful - I'm very, very new to Blender so please bear with me!
Achieving this with material nodes
I thought Generated and Object texture spaces differ and that can be used for this. Thanks to Robin Betts for figuring out the correct math.
Object's texture space goes from 0 to one in every direction on every axis from the origin of the object to the end of its bounding box in that axis, however Generated texture space matches the scale of global world space. If the origins of all objects are at their bottoms, their heights can be calculated by dividing the Z value of the object's texture space by the Z value of Generated texture space. The values can then be compressed to the desired range by dividing them by the height of the highest object. A Color Ramp node then can be used to remap the height values to colors: