Draw data not in rectangular shape

Hi there,

I've got a a pylab 2D array which I plot using imshow() which just works
fine. But part of the data within the array is not to be considered nor
plotted. To keep it simple let's assume the data I need is shaped like a
triangle. It is no problem to extract the data from the matrix
converting the matrix to a list and dropping all unnecessary data.

My problem is that I don't know how to plot the data again. A possible
work around would be to set data elements which I don't need to some
value not in the data. But I since I need to compute histograms for the
data, for example, I have to drop the data anyways. Is there a way to
solve my problem?

Thanks for your help.
Cheers,
Torsten

Hi Torsten,

Use NumPy masked arrays with imshow()
[http://docs.scipy.org/doc/numpy/reference/maskedarray.html\]. You can
use the masked array just as you have been using your regular NumPy
array, they are designed for this purpose and Matplotlib will not plot
the masked portion of your data.

The pylab interface actually imports numpy so your pylab array is
really a NumPy ndarray object (try calling >>> print
type(your_pylab_array) to see this).

Cheers,
Scott

···

On 1 February 2010 11:34, Torsten Andre <qa@...2949...> wrote:
I've got a a pylab 2D array which I plot using imshow() which just works
fine. But part of the data within the array is not to be considered nor
plotted.

My problem is that I don't know how to plot the data again.

Scott Sinclair wrote:

···

On 1 February 2010 11:34, Torsten Andre <qa@...2949...> wrote:
I've got a a pylab 2D array which I plot using imshow() which just works
fine. But part of the data within the array is not to be considered nor
plotted.

My problem is that I don't know how to plot the data again.

Hi Torsten,

Use NumPy masked arrays with imshow()
[http://docs.scipy.org/doc/numpy/reference/maskedarray.html\]. You can
use the masked array just as you have been using your regular NumPy
array, they are designed for this purpose and Matplotlib will not plot
the masked portion of your data.

The pylab interface actually imports numpy so your pylab array is
really a NumPy ndarray object (try calling >>> print
type(your_pylab_array) to see this).

Cheers,
Scott

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Hi Scott,

thank you very much. MA is exactly what I was looking for. Works
perfectly fine.

Cheers,
Torsten