nextstrain / auspice

Web app for visualizing pathogen evolution
https://docs.nextstrain.org/projects/auspice/
GNU Affero General Public License v3.0
292 stars 163 forks source link

Scatterplot sometimes uses different x-axis grid line densities for negative and positive values #1324

Open huddlej opened 3 years ago

huddlej commented 3 years ago

Current Behavior

When switching between different scatterplot variables, the grid lines for the x-axis appear at different densities for negative and positive values.

For example, in the following view of a PCA component vs. divergence, the negative value grid lines appear less frequently than the positive value lines.

image

This behavior only seems to affect the x-axis, since switching to the same variable on the y-axis does not cause different spacing of y-axis grid lines:

image

Strangely, not all variables with negative values are similarly affected as in this example of an MDS embedding:

image

Expected behavior

Both x and y axes should use consistent grid lines throughout the display.

How to reproduce

I don't have a good way to reproduce this from live data yet (I'm not sure how to view a deployment of Auspice with scatterplots other than my local version).

Your environment: if running Nextstrain locally

Operating system: Mac OS X Mojave 10.14.6 Browser: Chrome 89.0.4389.90 Version: master branch at commit 946e210

jameshadfield commented 3 years ago

Both x and y axes should use consistent grid lines throughout the display.

Agreed - 38201fb unified the function calls so they can be used for either axes. This issue stems from incorrect calculation of the minor grid lines for the axes in certain cases. Note that we don't plot minor grid lines for the y-axis, which is why "this behavior only seems to affect the x-axis". (We can easily plot them for the y-axis if we want to; I experimented with it but found the aesthetics a bit too busy.)

The bug here is within the computeNumericGridPoints function, however I was unable to reproduce it using the examples above (as in, the same views were correctly rendered for me, see screenshot below). I played with the code a bit to try to reproduce it but couldn't. Let's revisit this when we find a way to reproduce it, as while the display's not misleading it's not nice either!

image