[query] Fix old hl.plot.histogram log argument#11268
Conversation
| changes = { | ||
| "bin_freq": [math.log10(x) if x > 0.0 else x for x in data.bin_freq], | ||
| "n_larger": math.log10(data.n_larger) if data.n_larger > 0.0 else data.n_larger, | ||
| "n_smaller": math.log10(data.n_smaller) if data.n_smaller > 0.0 else data.n_smaller | ||
| } | ||
| data = data.annotate(**changes) |
There was a problem hiding this comment.
I think this is wrong, because it plots count-0 and count-1 bins the same. I think the right thing to do is log(x) if x > 0.0 else shift, where shift < 0 is arbitrary, but shift=-1 is as good as anything.
|
@patrick-schultz , shift = -1 can lead to some pretty ugly graphs when the range of log transformed y values is small (i.e. between 0 and 1) |
|
The negative 1 doesn't seem right, but we should probably give a warning or something when a user does this. I could log a warning telling user how many points were 0 and so weren't plotted? |
|
That seems good. Perhaps we could also suggest using |
|
|
…am would never work. Also have to handle the case where there are 0s
7683536 to
a016948
Compare

Struct fields are not mutable, so the log argument of hl.plot.histogram would never work. Also have to handle the case where there are 0s