|
44 | 44 | rcParams=matplotlib.rcParams |
45 | 45 |
|
46 | 46 |
|
| 47 | +def_has_item(data,name): |
| 48 | +"""Return whether *data* can be item-accessed with *name*. |
| 49 | +
|
| 50 | + This supports data with a dict-like interface (`in` checks item |
| 51 | + availability) and with numpy.arrays. |
| 52 | + """ |
| 53 | +try: |
| 54 | +returnnameindataornameindata.dtype.names |
| 55 | +except (AttributeError,TypeError): |
| 56 | +returnFalse |
| 57 | + |
| 58 | + |
47 | 59 | def_plot_args_replacer(args,data): |
48 | 60 | iflen(args)==1: |
49 | 61 | return ["y"] |
50 | 62 | eliflen(args)==2: |
51 | 63 | # this can be two cases: x,y or y,c |
52 | | -if (notargs[1]indataand |
53 | | -not (hasattr(data,'dtype')and |
54 | | -hasattr(data.dtype,'names')and |
55 | | -data.dtype.namesisnotNoneand |
56 | | -args[1]indata.dtype.names)): |
57 | | -# this is not in data, so just assume that it is something which |
58 | | -# will not get replaced (color spec or array like). |
| 64 | +if_has_item(data,args[1]): |
59 | 65 | return ["y","c"] |
60 | 66 | # it's data, but could be a color code like 'ro' or 'b--' |
61 | 67 | # -> warn the user in that case... |
|