Here are the relevant codepens to reproduce:
http://codepen.io/andrewkfiedler/pen/XNqMeW?editors=0010
http://codepen.io/andrewkfiedler/pen/ObZpzv?editors=0010
In the first codepen, you can see that plotting a histogram of type 'Number' causes future histograms to be assumed to be of type 'Number' as well. As such it throws an error (the second plot is attempted 5 seconds after the first, so wait 5 seconds).
In the second codepen, you can see that plotting a histogram of type 'String' causes future histograms to be assumed to be of type 'String' as well. As such, the numbers are binned as though they are strings.
Both are examples are using Plotly.newPlot.
What is the desired behavior here in your mind?
In my mind, Plotly should not crash when switching the type of data used in a histogram. 'Strings' are useful in histograms to bin things into categories, while 'Numbers' are useful to group things into ranges.
Using one type should not cause Plotly to assume that's the type for all future histograms.
I'd actually prefer being allowed to specify the type instead of allowing Plotly to make the decision for me, as right now I have to append a https://en.wikipedia.org/wiki/Zero-width_space in order to force String types that sometimes involve Numbers to be seen as such.
Anything else I can provide to help out on this?
Oh. You're using newPlot. Ok that's bad. Sorry I thought you were complaining about multi-trace graphs being cast to the same axis type. newPlot (as the name suggests) should clean up everything about the previous graphs.
Thanks for the report.
Changing the issue title to attract more attention.
The issue can be replicated all the back be to v1.0.0: not a regression.
We haven't fixed the bug yet, but here's a workaround: http://codepen.io/etpinard/pen/dOwJoZ
Our poor user input object management is responsible for this bug.
Just to be clear what @etpinard means by "poor user input object management" - the issue is that we mutate the layout object you pass in, so the workaround is to create a new layout object for each newPlot call.
We can only fix this in v2, at which point we can clone data and layout and mutate those rather than the ones you pass in.
Merging into https://github.com/plotly/plotly.js/issues/2234
Most helpful comment
Just to be clear what @etpinard means by "poor user input object management" - the issue is that we mutate the
layoutobject you pass in, so the workaround is to create a newlayoutobject for eachnewPlotcall.We can only fix this in v2, at which point we can clone
dataandlayoutand mutate those rather than the ones you pass in.