udibehar
(Ehud Behar)
1
Consider the following command:
Thread[{{1, 2, 3, 4}, {1, 4, 9, 16}}] // ListPlot
Now I want to pass into ListPlot the following option:
PlotStyle -> Black
so that the points appear in black color. Obviously, one can simply do
ListPlot[
Thread[{{1, 2, 3, 4}, {1, 4, 9, 16}}]
, PlotStyle -> Black]
But I would like to be able (if possible at all) to pass this black color additional option into ListPlot when I use the Postfix syntax.
Any idea about that?
This does the trick for your example
plot = Thread[{{1, 2, 3, 4}, {1, 4, 9, 16}}] // ListPlot;
plot/._RGBColor:>Black
hansmilton
(Hans Milton)
3
Thread[{{1, 2, 3, 4}, {1, 4, 9, 16}}] // ListPlot[#, PlotStyle → Black] &
udibehar
(Ehud Behar)
4
@Hans Milton
Thanks a lot! This is what I was looking for, opeartor form.
gdelfino
(Gustavo Delfino)
5
If you don’t like having too many & and # you can also do this:
Thread[{{1, 2, 3, 4}, {1, 4, 9, 16}}] //
OperatorApplied[ListPlot][PlotStyle->Black]
For more than one option, put them in a list:
Thread[{{1, 2, 3, 4}, {1, 4, 9, 16}}] //
OperatorApplied[ListPlot][{PlotStyle->Black, Frame->True}]
hansmilton
(Hans Milton)
6
If one feels that & and # are somewhat cryptic, here is an alternative to Gustavos example:
Thread[{{1, 2, 3, 4}, {1, 4, 9, 16}}] // Function[points, ListPlot[points, PlotStyle -> Black]]
You could also use Alan Calvitti’s magical “bullet” operator from this post .
\[Bullet] /: f_[pre___, \[Bullet], post___] :=
With[{n = Length[List@pre], m = Length[List@post]},
Curry[f, Join[Range[n], {n + m + 1}, Range[m] + n]][pre, post]];
After evaluating it
Thread[{{1, 2, 3, 4}, {1, 4, 9, 16}}] // ListPlot[\[Bullet], PlotStyle -> Black]
On a Mac \[Bullet] is Option + 8