0

I have the following data saved in data.dat, where the 3 columns are X, Y and Z respectively. X and Y are positions (angular offset from the center of a cube in arc seconds) and Z is the density in that position. How can I create a colorbar for Z in Python?

This is my data. First 2 values are positions

(27,0,8.26E+14),
(27,-18,8.57E+14),
(27,-18,8.57E+14),
(18,0,1.25E+15),
(9,0,1.13E+15),
(9,-9,9.53E+14),
(27,-18,8.38E+14),
(18,-18,7.96E+14),
(9,-18,6.71E+14),
(27,-18,5.20E+14)
Alex
  • 1,172
  • 11
  • 31
Rian
  • 111
  • 5
  • (27,0,8.26E+14),(27,-18,8.57E+14),(27,-18,8.57E+14),(18,0,1.25E+15), (9,0,1.13E+15),(9,-9,9.53E+14),(27,-18,8.38E+14),(18,-18,7.96E+14),(9,-18,6.71E+14),(27,-18,5.20E+14) This is my data. First 2 values are positions. – Rian Jul 15 '19 at 17:53
  • How can I make a 2D colomap for the same ? – Rian Jul 16 '19 at 02:54

1 Answers1

1

For your first four points the following can do what you are looking for

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

array3d = np.array([[27,0,8.26], [27,-18,8.57],[18, 0, 12.5],[9, 0, 11.3]])

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
pnt3d=ax.scatter(array3d[:,0],array3d[:,1],array3d[:,2],c=array3d[:,2])
cbar=plt.colorbar(pnt3d)
plt.show()

You can append the rest of your points in the array3d.

GioR
  • 596
  • 2
  • 8
  • 19