15,070,089 members

See more:

I am trying to plot heatmap with three variables x, y and z, each with vector length of 932826. The time taken with the function below is 28 seconds, with a bin size of 10 on each x and y. I have been using another program where the same plot happens in 6 - 7 seconds. Also, I know that the plot function of that program uses Python in the background

When debugging I see that the maximum time consumed is while using the griddata function. So, I was wondering if there are any alternatives that I can use instead of griddata to make the interpolation quicker

In future I will be handling even bigger data (8 to 10 times the size of current one), so I am in need to finding something robust, which handles all the data, without going into memory overflow

**What I have tried:**

When debugging I see that the maximum time consumed is while using the griddata function. So, I was wondering if there are any alternatives that I can use instead of griddata to make the interpolation quicker

In future I will be handling even bigger data (8 to 10 times the size of current one), so I am in need to finding something robust, which handles all the data, without going into memory overflow

Python

Copy Code

import numpy as np import matplotlib.pyplot as plt import time from scipy.interpolate import griddata import os arr_len = 932826 x = np.random.uniform(low=0, high=4496, size=arr_len) y = np.random.uniform(low=-74, high=492, size=arr_len) z = np.random.uniform(low=-30, high=97, size=arr_len) x_linspace = 10 y_linspace = 10 x_lab = 'x_label' y_lab = 'y_label' title = 'some title' plot_name = 'example plot' xi = np.linspace(min(x), max(x), x_linspace) yi = np.linspace(min(y), max(y), y_linspace) start = time.time() zi = griddata((x, y), z, (xi[None, :], yi[:, None]), method='linear') print('Time elapsed = ', time.time()-start)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900