Hi I have a data file with multiple column and I want to add a third axis with a colorbar. What I want to do is plot 1st column as y and 5th column as x axis also want to add 4th column with color on data points but I'm getting following error:
ValueError: to_rgba: Invalid rgba arg "124.12834"
to_rgb: Invalid rgb arg "124.12834"
gray (string) must be in range 0-1
my data file is as follows:
10.0 -1000.0 1300.0 2800.0 124.12834 426.450106 207.905003
10.0 -1000.0 1200.0 2000.0 127.856047 426.794984 230.104389
10.0 -500.0 1300.0 2800.0 123.074804 426.255793 205.883523
10.0 -500.0 1200.0 2000.0 127.10481 426.453441 228.650902
10.0 0.0 1300.0 2800.0 122.240729 425.953329 204.735877
10.0 0.0 1200.0 2000.0 126.435714 426.086112 227.646258
10.0 500.0 1200.0 2000.0 125.835211 425.704534 226.969429
and the code that im using is:
import numpy as np
import matplotlib.pyplot as plt
with open("test_data1.dat") as f:
data = f.read()
data = data.split('\n')
x = [row.split('\t')[5] for row in data]
y = [row.split('\t')[1] for row in data]
z = [row.split('\t')[4] for row in data]
cm = plt.cm.get_cmap('RdYlBu')
fig, ax = plt.subplots()
sc = ax.scatter(x, y, c=z, vmin=10, vmax=15,s=35.0,cmap=cm)
fig.colorbar(sc)
plt.show()
Note that it doesn't copy data with protecting all properties thus you can take following data this is the data string in the code:
['10.0\t-1000.0\t1300.0\t2800.0\t124.12834\t426.450106\t207.905003',
'10.0\t-1000.0\t1200.0\t2000.0\t127.856047\t426.794984\t230.104389',
'10.0\t-500.0\t1300.0\t2800.0\t123.074804\t426.255793\t205.883523',
'10.0\t-500.0\t1200.0\t2000.0\t127.10481\t426.453441\t228.650902',
'10.0\t0.0\t1300.0\t2800.0\t122.240729\t425.953329\t204.735877',
'10.0\t0.0\t1200.0\t2000.0\t126.435714\t426.086112\t227.646258',
'10.0\t500.0\t1200.0\t2000.0\t125.835211\t425.704534\t226.969429']
Thanks
