The debugger in the notebook interface can give more information about errors of this kind. Granted, that information is sometimes cryptic -- but it is better than no information at all.
Let's try it with the expressions from the question.
We'll start by going to the Evaluation menu to enable the Debugger option:

In the Debug palette that appears, click on Show Stack and tick the Break at Messages checkbox:

Now, evaluate the expressions. The first message will appear, the evaluation will be suspended, and the Stack window will show where the error occurred:

The bottom expression in the Stack window is Message
, which generated the message that we see. Above that is the offending expression, False[[True]]
. This was the result of evaluating the rather strange expression NumericQ[#1][[NumericQ[2]]]
. We can see that the head of this expression was generated from NumericQ /@ x
where x
is #1
.
The strange expression is unexpected and is a strong clue about what has gone wrong. Apparently, x
is being bound to all kinds of expressions, not just lists. Our pattern is not restrictive enough. We certainly want to restrict it to lists (e.g. x_List
), but I suspect that the condition needs to be stronger as well (depending on the goal).
Having concluded our analysis, we can either choose the Abort
or Finish
option from the Debug
palette, as suits our fancy.
It is not entirely clear to me what the purpose of these expressions are. If you are trying to extract the data from the plot then Cases
might be more appropriate than /.
, perhaps something like:
First @ Cases[p, Line[pts_] :> pts, Infinity, 1]
If the intent is to make minor tweaks to the Graphics
expression, then the pattern and condition will need to be restrictive enough to match only the desired list or lists of numbers.
InputForm[p]
gives the expression andShort[InputForm[p], 10]
gives the short form ofp
. Please look at it and say, what do you need to find/extract/replace. $\endgroup$ – Vahagn Poghosyan Sep 21 '13 at 0:02p /. Line[x_List] :> (data = x);
$\endgroup$ – Vahagn Poghosyan Sep 21 '13 at 0:13