-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect mpld3 plotting in log scale #227
Comments
This does look like a bug, and I'm not sure why it's happening. Here's a minimal snippet of code that reproduces the bug: import matplotlib.pyplot as plt
import mpld3
x = [1, 10, 100, 1000]
y = [1, 10, 100, 1000]
ax = plt.subplot(xscale='log', yscale='log')
ax.scatter(x, y)
mpld3.show() I think it has something to do with the translation/offset framework of path collections, but I'm not sure. Thanks for reporting this! |
The panning function doesn't also doesn't work for scatterplots when either of the axes is in log scale. This seems to be a problem only for scatter, and not plot. One work around is to use plot instead of scatter.
rather than
|
It's a poor workaround though, if one wants to color the points. |
You can set the point colors using the args 'markeredgecolor' and 'markerfacecolor' - so I think it's still a fine workaround. You have nearly all the same control over plot style with plot compared to scatter. plot docs here: https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.plot.html |
Forgot about that, but not exactly what I mean.
Anyway, thanks for your respond. |
Good point. Thanks for the clarification. Obviously, being able to use both scatter and plot as designed would be ideal. |
The workaround worked fine for me. 🎉 For those who are using import mpld3
fig, ax = plt.subplots()
ax.set_xscale('log', basex=10)
# because of the log axis, the scatter plot will not work fine
scatter = ax.scatter(x, y)
tooltips = mpld3.plugins.PointLabelTooltip(scatter, labels=labels)
mpld3.plugins.connect(fig, tooltips) The labels will not work if you only replace tooltips = mpld3.plugins.PointLabelTooltip(scatter[0], labels=labels)
# see here ----------------------------------------^ Hope that helps. :) |
There appears to be an problem plotting in log scale using mpld3 (v 1.3.1). This problem was reported on stackflow (http://stackoverflow.com/questions/25188903/incorrect-mpld3-plotting-in-log-scale?noredirect=1#comment39225554_25188903) and confirmed by another person.
Thanks.
-Sheldon
The text was updated successfully, but these errors were encountered: