How to display a 3D plot of a 3D array isosurface with mplot3D or similar

Just to elaborate on my comment above, matplotlib’s 3D plotting really isn’t intended for something as complex as isosurfaces. It’s meant to produce nice, publication-quality vector output for really simple 3D plots. It can’t handle complex 3D polygons, so even if implemented marching cubes yourself to create the isosurface, it wouldn’t render it properly. However, … Read more

Annotating a 3D scatter plot

Maybe easier via ax.text(…): from matplotlib import pyplot from mpl_toolkits.mplot3d import Axes3D from numpy.random import rand from pylab import figure m=rand(3,3) # m is an array of (x,y,z) coordinate triplets fig = figure() ax = fig.add_subplot(projection=’3d’) for i in range(len(m)): #plot each point + it’s index as text above ax.scatter(m[i,0],m[i,1],m[i,2],color=”b”) ax.text(m[i,0],m[i,1],m[i,2], ‘%s’ % (str(i)), size=20, … Read more

Plotting 3D Polygons

I think you’ve almost got it. Is this what you want? from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection import matplotlib.pyplot as plt fig = plt.figure() ax = Axes3D(fig, auto_add_to_figure=False) fig.add_axes(ax) x = [0,1,1,0] y = [0,0,1,1] z = [0,1,0,1] verts = [list(zip(x,y,z))] ax.add_collection3d(Poly3DCollection(verts)) plt.show() You might also be interested in art3d.pathpatch_2d_to_3d.

Plotting a 3d cube, a sphere and a vector

It is a little complicated, but you can draw all the objects by the following code: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np from itertools import product, combinations fig = plt.figure() ax = fig.gca(projection=’3d’) ax.set_aspect(“equal”) # draw cube r = [-1, 1] for s, e in combinations(np.array(list(product(r, r, r))), 2): … Read more

Make 3D plot interactive in Jupyter Notebook

try: %matplotlib notebook see jakevdp reply here EDIT for JupyterLab users: Follow the instructions to install jupyter-matplotlib Then the magic command above is no longer needed, as in the example: # Enabling the `widget` backend. # This requires jupyter-matplotlib a.k.a. ipympl. # ipympl can be install via pip or conda. %matplotlib widget # aka import … Read more

How to make a 3D scatter plot

You can use matplotlib for this. matplotlib has a mplot3d module that will do exactly what you want. import matplotlib.pyplot as plt import random fig = plt.figure(figsize=(12, 12)) ax = fig.add_subplot(projection=’3d’) sequence_containing_x_vals = list(range(0, 100)) sequence_containing_y_vals = list(range(0, 100)) sequence_containing_z_vals = list(range(0, 100)) random.shuffle(sequence_containing_x_vals) random.shuffle(sequence_containing_y_vals) random.shuffle(sequence_containing_z_vals) ax.scatter(sequence_containing_x_vals, sequence_containing_y_vals, sequence_containing_z_vals) plt.show() The code above generates a … Read more

ValueError: Unknown projection ‘3d’

First off, I think mplot3D worked a bit differently in matplotlib version 0.99 than it does in the current version of matplotlib. Which version are you using? (Try running: python -c ‘import matplotlib; print matplotlib.”__version__”) I’m guessing you’re running version 0.99, in which case you’ll need to either use a slightly different syntax or update … Read more

Changing the background color of the axes planes of a 3D plot

Using the same example. You can set the pane color using the set_pane_color method as described here http://matplotlib.org/mpl_toolkits/mplot3d/api.html#axis3d. You can set the color using the RGBA tuple: # scatter3d_demo.py # … # Set the background color of the pane YZ ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 1.0)) plt.show()

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)