Creating a heatmap using coordinates data

Viewed 20

I want to create a heat map using the following coordinate data points. The Base_TT is treatment time value in hours, which I want to plot against the coordinates.

enter image description here

I am reading an Excel file and making a data frame:

file_loc1 = "AgeGroupData_time_to_treatment.xlsx"

df_centroid_Coord = pd.read_excel(file_loc1, index_col=None, na_values=['NA'], usecols="C:D,AB")
df_centroid_Coord.head()

I have successfully generated a scatter plot with this data. Please have a look below.

enter image description here

This is code for scatter plot:

df_centroid_Coord.plot(x="x", y="y", kind="scatter", c="Base_TT",  colormap="PuBu")

Now, I want to plot the value of Base_TT against coordinates x, and y. My code is as follows:

ab = a.pivot("x", "y", "Base_TT")
sns.heatmap(ab, cmap ='RdYlGn', annot = True)

It is giving an output as follow:

enter image description here

Here, I am facing a problem. In total, I have 16622 rows × 3 columns data as can be seen in the data figure above. I want to plot the value of treatment time (Base_TT) against each coordinate to generate a heat map showing coordinates with corresponding values.

I want to achieve something like this.

enter image description here

But in this above screenshot, the values in x-axis and y-axis are random values. However, I want to use coordinates data and plot values against each.

0 Answers
Related