Skip to content
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

set_xlim in 3D scatter plots? #749

Closed
sb2nov opened this issue Mar 8, 2012 · 7 comments
Closed

set_xlim in 3D scatter plots? #749

sb2nov opened this issue Mar 8, 2012 · 7 comments

Comments

@sb2nov
Copy link

sb2nov commented Mar 8, 2012

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
Copy link
Author

sb2nov commented Mar 8, 2012

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

@sb2nov sb2nov closed this as completed Mar 8, 2012
@sb2nov sb2nov reopened this Mar 8, 2012
@ghost ghost assigned WeatherGod Mar 9, 2012
@WeatherGod
Copy link
Member

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
Copy link
Author

sb2nov commented Mar 9, 2012

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
Copy link

tomaasa commented Jul 24, 2012

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
Copy link
Member

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

@WeatherGod
Copy link
Member

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.

@ajdroid
Copy link

ajdroid commented Mar 16, 2018

Has anything changed, wrt this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants