2D Density Plot from a 2 columns DATA file

pythonaddicted at gmail.com pythonaddicted at gmail.com
Thu Jul 28 05:23:26 EDT 2016


I am trying from 2 days and I don't get a result. I have 3 thermometer and I repeat the measurement for 5 days.
I have a file of 2 columns: the first is the thermometer number, the second is the value of the thermometer.

For example:
1 25
2 37
3 24
1 18
2 36
3 48
1 37
2 24
3 15

It is clear that every 3 rows, from the beginning, I have a day.

Now I would like to make a 2D density plot like this http://stackoverflow.com/questions/4128699/using-scipy-stats-gaussian-kde-with-2-dimensional-data
I just use the two columns of my file:


    # Create some dummy data
    rvs = np.append(X,
                    Y,
                    axis=1)

instead of:

    # Create some dummy data
    rvs = np.append(stats.norm.rvs(loc=2,scale=1,size=(2000,1)),
                    stats.norm.rvs(loc=0,scale=3,size=(2000,1)),
                    axis=1)


but i got this message:

    x_flat = np.r_[rvs[:,0].min():rvs[:,0].max():128j]
    IndexError: invalid index


What is wrong?

Of course I have not a very dense distribution, but a dense distribution along Y, but I would call "discrete" distribution along X. Could be nice having a bin, along X, of dimension 1.

Thanks in advance!
Anita.



More information about the Python-list mailing list