[SciPy-User] density map?
Fernando Paolo
fspaolo@gmail....
Mon Aug 29 18:35:37 CDT 2011
If what you want is to plot the intensities ("on a grid"), and you
have a 2-D Numpy array (`data`) where the columns are (say) `x`, `y`,
`z`, you can do:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.mlab import griddata
x = data[:,0]
y = data[:,1]
z = data[:,2]
# define the grid: nx, ny == number of grid points
xi = np.linspace(x.min(), x.max(), nx)
yi = np.linspace(y.min(), y.max(), ny)
# interpolate your data to a regular grid
Zi = ml.griddata(x, y, z, xi, yi)
# plot a continuous surface
plt.contourf(xi, yi, Zi, 15, cmap=plt.cm.jet)
plt.colorbar()
plt.show()
you can check:
http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
-Fernando
On Mon, Aug 29, 2011 at 4:05 PM, <josef.pktd@gmail.com> wrote:
> On Mon, Aug 29, 2011 at 7:03 PM, <josef.pktd@gmail.com> wrote:
>> On Mon, Aug 29, 2011 at 6:58 PM, Sebastian Bassi <sbassi@gmail.com> wrote:
>>> Hello,
>>>
>>> I have a 2-D Numpy array with intensity data.
>>> I'd like to plot it like this
>>> http://crocdoc.ifas.ufl.edu/images/posters/ecologyofgatorholes/9_figure6.gif
>>> For each value in a position, it will be colored with a color, if the
>>> value is higher the color will be more intense (maybe from blue to
>>> red).
>>> All examples I found on http://www.scipy.org/Cookbook/Matplotlib/ were
>>> using functions instead of data from a matrix/array.
>>> Any idea?
>>
>> scipy.stats.gaussian_kde
>>
>> https://picasaweb.google.com/106983885143680349926/Joepy#5611180522655961714
>>
>> or some other non-parametric density estimator
>
> That's not the right answer, I guess if you have already intensities,
> then you don't need to estimate the density anymore.
>
> Is it interpolation to a meshgrid that you need?
>
> Josef
>
>>
>> Josef
>>
>>
>>> Best,
>>> SB.
>>> _______________________________________________
>>> SciPy-User mailing list
>>> SciPy-User@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>>
>>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
--
Fernando Paolo
Institute of Geophysics & Planetary Physics
Scripps Institution of Oceanography
University of California, San Diego
9500 Gilman Drive
La Jolla, CA 92093-0225
More information about the SciPy-User
mailing list