5

How could I plot the following data in 3 dimensions? (apparently, there are more than that!)

data = [[10, 10, 0.84496124031007758],
 [10, 20, 0.87209302325581395],
 [10, 30, 0.88139534883720927],
 [20, 10, 0.86201550387596892],
 [20, 20, 0.87441860465116272],
 [20, 30, 0.88992248062015500],
 [30, 10, 0.87984496124031009],
 [30, 20, 0.89922480620155043],
 [30, 30, 0.92015503875968996]]
Trenton McKinney
63.2k41 gold badges170 silver badges214 bronze badges
asked Oct 9, 2013 at 19:23

3 Answers 3

8

what kind of plot are you trying to get? Try this for a scatter plot. I'm also assuming your data is listed in x,y,z lists in your question.

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
x, y, z = zip(*data)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x,y,z)
plt.show()
answered Oct 9, 2013 at 19:47
Sign up to request clarification or add additional context in comments.

Comments

0

You can also use DataMelt http://jwork.org/dmelt. You can parse this file in pythonic way as in the previous example ANF than use HPlot or HPlotJa or SPlot java classes to visualize the data. You can also export to Esp or pdf image files

answered Jul 3, 2018 at 5:00

Comments

0

It's basicaly adding projection='3d' to your subplot.

import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure() # create new figure
ax = fig.add_subplot(projection='3d') # add 3d plot
n = 100 # number of points
# random points
x = np.random.rand(n)
y = np.random.rand(n)
z = np.random.rand(n)
# make and show plot
ax.scatter(x, y, z)
plt.show()

With ax.scatter you can configure points markers, color and others.

Looks like the figure enter image description here

answered Dec 29, 2020 at 8:42

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.