Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

set_xlim in 3D scatter plots? #749

Closed
sb2nov opened this Issue · 6 comments

3 participants

@sb2nov

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.

@sb2nov

Also the color is lost as soon as you move the grid around.

@sb2nov sb2nov closed this
@sb2nov sb2nov reopened this
@WeatherGod WeatherGod was assigned
@WeatherGod
Collaborator

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.

@sb2nov

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.

@tomaasa

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

@WeatherGod
Collaborator

Works fine for me on v1.1.x. What happens for you when you run that code?

@WeatherGod
Collaborator

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.

@WeatherGod WeatherGod closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.