From: Nasser Abbasi on
Problem: Make a ListPlot, and have each Point be a different color.
Solution: Use Directive

ListPlot[{{{1, 1}}, {{2, 3}}},
PlotStyle -> {Directive[Red], Directive[Blue]},
AxesOrigin -> {0, 0}]

Problem : Make a ListPlot, but with vertical lines, and have each line be a
different color.

You would expect the synatx to be the same as above, just use Filling->Axis
and use FillingStyle-> insteadl of PlotStyle->, right? But it does not work

Solution attempt:

ListPlot[{{{1, 1}}, {{2, 3}}},
Filling -> Axis,
FillingStyle -> {Directive[Red], Directive[Blue]},
AxesOrigin -> {0, 0}]

Now I looked at help, and it says:

"Directives can be combined using Directive[g1,g2,....]"

So, I tried this

ListPlot[{{{1, 1}}, {{2, 3}}},
Filling -> Axis,
FillingStyle -> Directive[Red, Blue],
AxesOrigin -> {0, 0}]

And this did not work either. I also tried

ListPlot[{{{1, 1}}, {{2, 3}}},
FillingStyle -> {Red, Blue},
AxesOrigin -> {0, 0},
Filling -> Axis]

I also tried

ListPlot[{{{1, 1}}, {{2, 3}}},
FillingStyle -> Directive[{Red, Blue}],
AxesOrigin -> {0, 0},
Filling -> Axis]

Am I getting any closer? I tried above 10 other ways, and can't get it to do
this. so I give up :)

Any idea how to make each vertical line be colored differently according to
my own list of colors?

thanks,
--Nasser







From: David Park on
Nasser,

Sometimes it is such a chore to screw around a set-piece plot to a custom
plot. (But some people on this list are good at it.) If each line is to have
its own custom style why not abandon ListPlot and do something like this:

filledLine[color_, {x_, y_}] := {color,
Style[Line[{{x, y}, {x, 0}}], Antialiasing -> False],
Directive[color, AbsolutePointSize[4]], Point[{x, y}]}

Graphics[{filledLine @@@ {{Red, {1, 1}}, {Blue, {2, 3}}}},
AspectRatio -> .6,
Frame -> True,
PlotRange -> {{-.1, 2.2}, {0, 3.2}}]

You could allow more style options in the filledLine routine, depending on
your needs. Since all the filled lines are vertical we can make them crisper
using the Antialiasing option.


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/


From: Nasser Abbasi [mailto:nma(a)12000.org]

Problem: Make a ListPlot, and have each Point be a different color.
Solution: Use Directive

ListPlot[{{{1, 1}}, {{2, 3}}},
PlotStyle -> {Directive[Red], Directive[Blue]},
AxesOrigin -> {0, 0}]

Problem : Make a ListPlot, but with vertical lines, and have each line be a
different color.

You would expect the synatx to be the same as above, just use Filling->Axis
and use FillingStyle-> insteadl of PlotStyle->, right? But it does not work

Solution attempt:

ListPlot[{{{1, 1}}, {{2, 3}}},
Filling -> Axis,
FillingStyle -> {Directive[Red], Directive[Blue]},
AxesOrigin -> {0, 0}]

Now I looked at help, and it says:

"Directives can be combined using Directive[g1,g2,....]"

So, I tried this

ListPlot[{{{1, 1}}, {{2, 3}}},
Filling -> Axis,
FillingStyle -> Directive[Red, Blue],
AxesOrigin -> {0, 0}]

And this did not work either. I also tried

ListPlot[{{{1, 1}}, {{2, 3}}},
FillingStyle -> {Red, Blue},
AxesOrigin -> {0, 0},
Filling -> Axis]

I also tried

ListPlot[{{{1, 1}}, {{2, 3}}},
FillingStyle -> Directive[{Red, Blue}],
AxesOrigin -> {0, 0},
Filling -> Axis]

Am I getting any closer? I tried above 10 other ways, and can't get it to do

this. so I give up :)

Any idea how to make each vertical line be colored differently according to
my own list of colors?

thanks,
--Nasser