When creating a bubble plot, a colour for the bubbles can be configured. If the variable to use for this colouring has 0 as either its minimum or maximum value, there will be no colour difference between the bubbles. See images below for an example of this problem.
The truth_13tev parameter controlling the colour in these widgets is binary, being either 0 or 1 for each individual data point and the average of this variable changes from bubble to bubble. This behaviour is the result of line 38 to line 43 in src/widgets/views/chartjs2d.js, that control the normalisation of the data for both the bubble colouring and the bubble radius. These lines state
} else if ((max > 0 && min > 0) || (max < 0 && min < 0)) {
// linear map v from [min, max] to [0,1]
norm = function (v) {
return (v - min) / (max - min);
};
}
Changing this to
} else if ((max > 0 && min >= 0) || (max <= 0 && min < 0)) {
// linear map v from [min, max] to [0,1]
norm = function (v) {
return (v - min) / (max - min);
};
}
solves the problem and produces the following (correct) bubble plot in my locally running (and altered) version of spot (data was not identical, hence there are some missing bubbles):
I've tested whether this ruins other functionality of the bubble plots and this seems not to be the case. If okay with you, I would like to make a pull request that fixes this error.
I have taken the liberty to create a pull request (#206) that implements the proposed solution, so that if everyone is okay, nobody has to dive into the code to make the proposed change :-)
When creating a bubble plot, a colour for the bubbles can be configured. If the variable to use for this colouring has 0 as either its minimum or maximum value, there will be no colour difference between the bubbles. See images below for an example of this problem.
The
truth_13tev
parameter controlling the colour in these widgets is binary, being either 0 or 1 for each individual data point and the average of this variable changes from bubble to bubble. This behaviour is the result of line 38 to line 43 insrc/widgets/views/chartjs2d.js
, that control the normalisation of the data for both the bubble colouring and the bubble radius. These lines stateChanging this to
solves the problem and produces the following (correct) bubble plot in my locally running (and altered) version of spot (data was not identical, hence there are some missing bubbles):
I've tested whether this ruins other functionality of the bubble plots and this seems not to be the case. If okay with you, I would like to make a pull request that fixes this error.