I am trying to plot two 1-D masked arrays against each other in a line plot and an extraneous straight line appears on the plot. This phenomenon only occurs sporadically and with certain data sets. I have noticed a similar phenomenon with masked arrow arrays, but that is much harder to track down. The masked elements are intended to break the plot line so that several independent polylines are plotted. (The purpose is to plot a map of coastal outlines.)
I am attaching a python script which reproduces the problem, but only with a particular data set, which is also attached. Sorry, if I try to shorten the data set more than I have already, the problem goes away, even if I split the file in half an plot each half separately! I am running on a 32 bit intel processor using debian testing and the numpy and matplotlib versions are 1.3 and 0.99.1.2. However, the problem also appears on a 64 bit amd processor running debian stable with numpy and matplotlib versions 1.3 and 0.99.1.1. The python script is named maskbug.py and the data set is trunc1.dat, which is an ascii file. The data set should be read on the standard input, i. e., maskbug.py < trunc1.dat I have verified by printing the masked arrays that nothing appears to go wrong in the conversion from ascii to numpy masked array. Dave Raymond Physics Dept. New Mexico Tech Socorro, NM 87801
#!/usr/bin/python # this illustrates a bug which occurs when plotting masked data import sys from numpy import * import matplotlib.pyplot as plt # get lon-lat data from standard input and store in lists lonl = [] latl = [] while 1: inline = sys.stdin.readline() if inline == '': break else: pieces = inline.split() lonl.append(float(pieces[0])) latl.append(float(pieces[1])) # convert lists to numpy arrays lon = array(lonl) lat = array(latl) # compute masks -- masked elements have values of 1.e30 masklon = lon > 0.999e30 masklat = lat > 0.999e30 # compute masked arrays mlon = ma.array(lon, mask = masklon) mlat = ma.array(lat, mask = masklat) # list input file print mlon print mlat # plot them cc = plt.plot(mlon,mlat) ax = plt.axis([120,150,0,30]) plt.show()
trunc1.dat
Description: Netscape Proxy Auto Config
------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel