While plotting a 3D scatter plot, if you set axis limits to be lesser than the the maximum range of the array.
The array values are plotted outside the axis area.
In the 2D equivalent, those values are ignored.
if x = [1, 2, 3, 4, 5, 6 ,7]
then ax.set_xlim(2, 6)
this still plots the 1 and 7 value.
Also the color is lost as soon as you move the grid around.
The issue you are seeing is that the collection object returned by scatter() does not know how to properly "clip" the results. This is actually a very tricky problem to solve with the way matplotlib is currently designed. For 2D plots, this is handled by clipping anything that falls outside the graph area. Because mplot3d tries to operate within the 2D rendering framework, you can see that those scatter points are clipped "properly" in a sense because you don't see them outside the white region. It will take some work to fix this issue, and probably can't be solved until OpenGL support is brought into matplotlib.
As for the color-changing issue, this is another known bug and I have yet to nail down a proper solution to it.
The temp. solution to the problem I used was to create a copy of the plotting array and then fill the region outside the limits with NAN. But that isn't something that can be made permanent.
Replacing irrelevant data in arrays with NaN can be used for plots and wireframes/surfaces. Did not work with scatter though. https://sites.google.com/site/scigraphs/home/posts/clip3darraypointsoutsideofaxes
Works fine for me on v1.1.x. What happens for you when you run that code?
This is an old issue that would require the backends to know how to do 3d bbox clipping. Given that the backends are 2D based, I just don't see how this will be possible any time soon. Therefore, I am closing this issue as "wontfix", but note that if/when mpl gains an OpenGL backend, this may change.