# Adding plot options after @ in ListLinePlot [closed]

How can plot options like PlotLabel and PlotRange be added after @ in ListLinePlot? For example:

 V1 = 1;  ListPlot@Table[{n, f /. FindRoot[ V1/4 + (f V1)/4 + 1/(4 (-1 + n) Gamma[1/2 (-1 + n)]^2) n^(1/2 (-3 - n)) (f V1)^(1/2 (-1 + n)) ((-1 + n) n^(3/2) V1^(3/2) Gamma[1/2 (-1 + n)]^2 (2 Sqrt[f] (-1 + n) (n/(f V1))^(n/2) - (1 + n) (n/V1)^(n/2) Hypergeometric2F1[1/2 (-1 + n), -1 + n, n, 1 - f]) - 2 (-1 + n)^2 Sqrt[n] (n/V1)^(n/2) V1^(3/2) Gamma[1/2 (-1 + n)] Gamma[(1 + n)/2] Hypergeometric2F1[n, (1 + n)/2, 1 + n, 1 - f]+ (-5 + n) V1 Gamma[1/2 (-5 + n)] (n Gamma[(3 + n)/2] (2 (-1 + n) (n/(f V1))^((1 + n)/2) V1 - f (-3 + n) (n/V1)^((1 + n)/2) V1 Hypergeometric2F1[-1 + n, (3 + n)/2, n, 1 - f])- 2 f (-1 + n) (n/V1)^((1 + n)/2) V1 Gamma[(5 + n)/2] Hypergeometric2F1[n, (5 + n)/2, 1 + n, 1 - f])) == 0, {f, 6}]}, {n, 2.001, 10.001, 0.1}]

• Why do you need to add them after the @? Why not ListLinePlot[#, PlotRange -> All] & @? – Rohit Namjoshi Sep 14 at 6:47
• You cannot do this - the @ operator is specifically for cases where you do not need to add any further arguments or options to your function. Just do as Rohit mentions, or simply wrap the entire Table expression with ListPlot[..., PlotLabel->"Whatever"]. – Carl Lange Sep 14 at 8:36
• To add options that are also options for Show you can use postfix ... // Show[#, PlotLabel -> "Label"] & – kglr Sep 14 at 9:15

Note: This will probably only confuse people in the future. I suggest you use what was proposed in the comments for actual code.

If you are really determined, you could do something like this:

(args : Except[_addArgs] ..) /* addArgs[newArgs___] ^:= Sequence[args, newArgs]


You can use it like this:

(* multiple options in one *)
ListPlot@Table[i^2, {i, 10}] /* addArgs[PlotStyle -> Red, GridLines -> Automatic]


(* chain multiple addArgs[...] together *)
(* same output *)


This (ab)uses the fact that /* (RightComposition) has higher precedence than @, so the grouping of the arguments is automatically correct. Now we just need an up-value (defined via ^:= (TagSetDelayed)) that transforms expressions of the form arg1 /* addArgs[arg2] into Sequence[arg1, arg2]. The Except part is needed to enable chaining, since it ensures that the addArgs expressions are evaluated left-to-right to produce one proper Sequence of arguments.

I often find myself in the same position as OP, I was using the prefix operator but then I find I need to add more arguments. This is my workflow:

1. Highlight the @ symbol and change it to a [

2. Move the cursor to just after the next expression and add a ]

3. Move the cursor back one space and start typing options or arguments.

• This is obviously the correct answer. It's almost too simple, of course, since this is just using the language as designed, but that doesn't make it not the right answer. – b3m2a1 Sep 15 at 1:23

As mentioned in comments one option is to use pure function

V1 = 1;
mytable=Table[{n, f /. FindRoot[ V1/4 + (f V1)/4 + 1/(4 (-1 + n) Gamma[1/2 (-1 + n)]^2) n^(1/2 (-3 - n)) (f V1)^(1/2 (-1 + n)) ((-1 + n) n^(3/2) V1^(3/2) Gamma[1/2 (-1 + n)]^2 (2 Sqrt[f] (-1 + n) (n/(f V1))^(n/2) - (1 + n) (n/V1)^(n/2) Hypergeometric2F1[1/2 (-1 + n), -1 + n, n, 1 - f]) - 2 (-1 + n)^2 Sqrt[n] (n/V1)^(n/2) V1^(3/2) Gamma[1/2 (-1 + n)] Gamma[(1 + n)/2] Hypergeometric2F1[n, (1 + n)/2, 1 + n, 1 - f]+ (-5 + n) V1 Gamma[1/2 (-5 + n)] (n Gamma[(3 + n)/2] (2 (-1 + n) (n/(f V1))^((1 + n)/2) V1 - f (-3 + n) (n/V1)^((1 + n)/2) V1 Hypergeometric2F1[-1 + n, (3 + n)/2, n, 1 - f])- 2 f (-1 + n) (n/V1)^((1 + n)/2) V1 Gamma[(5 + n)/2] Hypergeometric2F1[n, (5 + n)/2, 1 + n, 1 - f])) == 0, {f, 6}]}, {n, 2.001, 10.001, 0.1}];


Compare these two lines:

ListPlot@mytable
ListPlot[#] &@mytable


They are effectively the same, however in the latter case you can add options after pure function

ListPlot[#, PlotRange -> {-10, 10}, PlotLabel -> "label"] &@mytable


You can also use infix notation. If there is more than one option, wrap them with Sequence:

mytable~ListPlot~Sequence[PlotRange -> {-10, 10}, PlotLabel -> "label"]


If you have to you can add some options using Show or MapAt or ReplacePart as post-fix:

ListPlot @ Table[i^2, {i, 10}] //
Show[#, PlotLabel -> "LABEL", GridLines -> Automatic] &

ListPlot@Table[i^2, {i, 10}] //
MapAt[Join[#, {PlotLabel -> "LABEL", GridLines -> Automatic}] &, #, {2}] &

ListPlot@Table[i^2, {i, 10}] //
ReplacePart[#, {2} -> Join[#[[2]], {PlotLabel -> "LABEL", GridLines -> Automatic}]] &


all three give