I've three columns in a text file, the first 2 columns represent the x-axis and y-axis positions, and I am trying to plot the third column at x and y-axis. The third column consists of 0-5 numbers.
I've tried the following code, but it doesn't give me the required result.
import numpy as np
import matplotlib.pyplot as plt
x, y, z = np.loadtxt('test.txt', delimiter=' ', unpack=True)
plt.plot(x, '.', y, '.', z)
plt.xlabel('Distance in meters')
plt.ylabel('Distance in meters')
plt.title('distribution of values')
plt.legend()
plt.show()
Here is the sample txt file.
2411.02 3310.21 3
-1246.65 -3098.39 4
166.298 6042.84 0
----
-51.7214 -2374.09 5
7285.08 661.326 0
-1390.51 4438.9 2
-2741.8 466.014 5
0 0 0
Figure shows the actual plot I got from the below code. However, the 3rd value should be plotted in a circular form based on the x and y-axis positions.
This is the output figure:
Solved with help of these resources: enter link description here and enter link description here
Code:
x, y, z = np.loadtxt('test.txt', delimiter=' ', unpack=True)
plt.scatter(x, y, c=z)
plt.show()