Description
Consider these 3 data series, where each of which I want to plot.
"2017M06" : 0.041601, 0.041601, 0.041601, 0.041601
"2017M07" : 0.032993, 0.037393, -0.00078 , 0.0289
"2017M08" : 0.035036, 0.00589 , 0.021899, 0.047374
Please see the following Python code.
step_in_between=0.01
starting_value=-0.2
ending_value=0.1
iplot(
{'data': [
{'histfunc': 'count',
'histnorm': 'probability',
'marker': {'color': 'rgba(255, 153, 51, 1.0)',
'line': {'color': '#4D5663', 'width': 3}},
'name': '2017M06',
'opacity': 0.8,
'orientation': 'v',
'type': 'histogram',
'x': [0.041601, 0.041601, 0.041601, 0.041601],
'xbins': {'end':ending_value, 'size':step_in_between, 'start': starting_value}
},
{'histfunc': 'count',
'histnorm': 'probability',
'marker': {'color': 'rgba(55, 128, 191, 1.0)',
'line': {'color': '#4D5663', 'width': 3}},
'name': '2017M07',
'opacity': 0.8,
'orientation': 'v',
'type': 'histogram',
'x': [0.032993, 0.037393, -0.00078 , 0.0289 ],
'xbins': {'end':ending_value, 'size':step_in_between, 'start': starting_value}
},
{'histfunc': 'count',
'histnorm': 'probability',
'marker': {'color': 'rgba(50, 171, 96, 1.0)',
'line': {'color': '#4D5663', 'width': 3}},
'name': '2017M08',
'opacity': 0.8,
'orientation': 'v',
'type': 'histogram',
'x': [0.035036, 0.00589 , 0.021899, 0.047374],
'xbins': {'end':ending_value, 'size':step_in_between, 'start': starting_value}
}
],
'layout': {'barmode': 'overlay',
}}
)
For whatever reason, the starting value "-0.2 " is not respected while the ending value "0.1" is respected. So, that is problem 1.
We have another interesting issue issue when I commented out "xbins" parameter.
step_in_between=0.01
starting_value=-0.2
ending_value=0.1
iplot(
{'data': [
{'histfunc': 'count',
'histnorm': 'probability',
'marker': {'color': 'rgba(255, 153, 51, 1.0)',
'line': {'color': '#4D5663', 'width': 3}},
'name': '2017M06',
'opacity': 0.8,
'orientation': 'v',
'type': 'histogram',
'x': [0.041601, 0.041601, 0.041601, 0.041601],
#'xbins': {'end':ending_value, 'size':step_in_between, 'start': starting_value}
},
{'histfunc': 'count',
'histnorm': 'probability',
'marker': {'color': 'rgba(55, 128, 191, 1.0)',
'line': {'color': '#4D5663', 'width': 3}},
'name': '2017M07',
'opacity': 0.8,
'orientation': 'v',
'type': 'histogram',
'x': [0.032993, 0.037393, -0.00078 , 0.0289 ],
#'xbins': {'end':ending_value, 'size':step_in_between, 'start': starting_value}
},
{'histfunc': 'count',
'histnorm': 'probability',
'marker': {'color': 'rgba(50, 171, 96, 1.0)',
'line': {'color': '#4D5663', 'width': 3}},
'name': '2017M08',
'opacity': 0.8,
'orientation': 'v',
'type': 'histogram',
'x': [0.035036, 0.00589 , 0.021899, 0.047374],
# 'xbins': {'end':ending_value, 'size':step_in_between, 'start': starting_value}
}
],
'layout': {'barmode': 'overlay',
}}
)
This is clearly very misleading. The default xbins is messed up where there is no variation in the data. In this particular example, the xbins for "2017M06" is literally 20 times more than the other two series. It can easily be misinterpreted as any value between 0 and 1 is equally likely for 2017M06. This is problem #2.
I attempted to fix it using 'nbinsx" parameter. That does not work as well.