pyplot 3D

My work with pyplot continues. I spent some time today working with 3D plots. matplotlib (the parent library of pyplot) does a great job making 3D plots with very little code, but it doesn’t quite go far enough to make it trivial.

In my particular case, I had a big collection of 3 dimensional data points. These were actually motion control points related to acceleration, velocity, and brake, but you could just as easily imagine these as lidar points with x, y, and z coordinates.

In a perfect world, I’d pass these points to pyplot and get a 3D plot.

In an even more perfect world, I’d pass these points to pyplot and get a 3D contour.

Unfortunately, the world is not perfect. Although it is still pretty awesome that pyplot can create these types of plots in a Jupyter notebook. I just have to configure the data properly.

I took a while to wrap my head around this, but specifically what it turns out I need to do is find a discrete set of x values, and a discrete set of y values, such that I have the z value for every combination of x and y.

It would have been great if pyplot could have interpolated (“filled in the blanks”) from the values I had at hand. But as far as I can tell, pyplot doesn’t do that.

At first I thought that might sink me, but then I realized that if I chose my z-coordinate properly, and scaled back the range of my y-coordinates, I could achieve this.

The plot wound up looking kind of boring, but boring in this case was good! If it were interesting, I might have been obliged to discard my linear model and start looking for something polynomial. A boring plot means I get to keep my boring (and manageable!) linear model 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s