Message Boards Message Boards

GROUPS:

Make a conditional plot?

Posted 5 months ago
406 Views
|
1 Reply
|
0 Total Likes
|

Hi, i want to make a plot like this type:

If[Abs[angle1] < 10, ListPlot[angle1]]

How is it possible to do with Mathematica?

That's a way

ListPlot[RandomReal[{-20, 20}, 100] /. x_Real :> If[Abs[x] > 10., 0, x], PlotRange -> {Automatic, {-11, 11}}]

please note, if angle1 is a list (because it appears in ListPlot[]) then Abs[angle1] threads over the list angle1 and Abs[angle1] < 10 is meaningless and comes back unevaluated. Just try subexpressions before using them:

In[9]:= l = {1, -2, 3, -4, 5, -5, 7};

In[10]:= Abs[l]
Out[10]= {1, 2, 3, 4, 5, 5, 7}

In[11]:= Abs[l] < 10
Out[11]= {1, 2, 3, 4, 5, 5, 7} < 10
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract