2

Simple example:

Normally: ListPlot[list, Joined->True]

If I want to map ListPlot how do I keep the Joined option?

thanks.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263

1 Answers1

6

If you consider the following lists:

SeedRandom@1; list1 = RandomReal[{0, 10}, {10, 2}];
SeedRandom@2; list2 = RandomReal[{0, 10}, {10, 2}];

One can easily Map ListPlot by doing:

Map[ListPlot, {list1, list2}]
(* eq. to: ListPlot /@ {list1, list2} *)

Mathematica graphics

If you want to use Options with the ListPlot you need to define a function with the options in place. You can use either a conventional pattern-based function:

lp[x_] := ListPlot[x, Joined -> True, PlotMarkers -> Automatic]

or you could use a pure function:

lp = ListPlot[#, Joined -> True, PlotMarkers -> Automatic]&

Then you can use it as follows:

Map[lp, {list1, list2}]
(* eq. to: lp /@ {list1, list2} *)

Mathematica graphics

Of course, it can still be used without Map:

lp[{list1, list2}]

Mathematica graphics

Öskå
  • 8,587
  • 4
  • 30
  • 49