-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Marker sizes in Axes3D scatter plot are changing all the time #19787
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
Comments
This bisects to e6d9cbb (#18189) Ping @tacaswell. |
Well, that is quite bad. Thank you for the bisect @jklymak Looking at this now. |
The issue is that when we re-compute the 3D projection we resort the values based on their depth from the viewer (so markers "in the back" do not render "in the front"). We have a bunch of logic to make sure that the colors also track, but we need the same logic to be added to the size. if you add color to this example you see that they keep their colors even if their sizes jump around. import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
# matplotlib 3.4
ax = Axes3D(fig, auto_add_to_figure=False)
fig.add_axes(ax)
# matplotlib 3.3.4
# Axes3D(fig)
x = np.random.rand(200)
y = np.random.rand(200)
z = np.random.rand(200)
ax.scatter(x, y, z, s=x*50, c=x**2)
plt.show() |
Attn @QuLogic This appears to be super broken. I have been testing with: th = np.linspace(0, 2*np.pi*6, 2000)
x = np.sin(th)
y = np.cos(th)
z = th
sc = ax.scatter(x, y, z, s=(5 + th), c=th**2) which has both a color and size structure I can predict what should be. |
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
try:
# matplotlib 3.4
ax = Axes3D(fig, auto_add_to_figure=False)
fig.add_axes(ax)
except AttributeError:
# matplotlib 3.3.4
ax = Axes3D(fig)
if ax not in fig.axes:
fig.add_axes(ax)
th = np.linspace(0, 2*np.pi*6, 2000)
x = np.sin(th)
y = np.cos(th)
z = th
sc = ax.scatter(x, y, z, s=(5 + th), c=th**2)
fig.savefig('/tmp/a.png')
fig.savefig('/tmp/b.png')
plt.show() OK, figured out why this passed tests (at least as far as the size goes, the first render is right!): It also looks like all of our tests with 3D scatter than do not have fixed color are using the figure comparison method so they are wrong together and we missed the color regression 😞 . |
v3.3.4#19812 |
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib as mpl
fig = plt.figure()
try:
# matplotlib 3.4
ax = Axes3D(fig, auto_add_to_figure=False)
fig.add_axes(ax)
except AttributeError:
# matplotlib 3.3.4
ax = Axes3D(fig)
if ax not in fig.axes:
fig.add_axes(ax)
th = np.linspace(0, 2 * np.pi * 6, 2000)
x = np.sin(th)
y = np.cos(th)
z = th
sc = ax.scatter(x, y, z, s=(1 + th * 5), c=th ** 2)
fig.suptitle(mpl.__version__)
fig.savefig("/tmp/a.png", bbox_inches="tight")
fig.savefig("/tmp/b.png")
fig.savefig("/tmp/c.png")
plt.show() |
Bug report
Bug summary
The marker sizes that specified with
s=
argument inscatter
function are wrong, and even worse, the markers are changing their sizes every time the plot is re-rendered (panning or resizing). It seems that the sizes are randomly reassigned to these markers.Code for reproduction
Actual outcome
matplotlib_axes3d_marker_size_issue.mp4
Expected outcome
As shown in the screen recording, the sizes are correct and not changing.
matplotlib
was 3.3.4 in the following example.matplotlib_axes3d_marker_size_expected.mp4
Matplotlib version
import matplotlib; print(matplotlib.__version__)
): 3.4.0print(matplotlib.get_backend())
): Qt5AggI installed both python, numpy and matplotlib with
pacman
package manager from Arch's official repository.The text was updated successfully, but these errors were encountered: