# How to set same color and legend for ListLinePlot

conn = {{{0, 0}, {10, 0}}, {{0, 0}, {10, 10}}, {{10, 0}, {10, 10}},
{{10, 0}, {20, 0}}, {{10, 10}, {20, 0}}, {{10, 10}, {20, 10}},
{{20, 0}, {20, 10}}, {{20, 0}, {30, 0}}, {{20, 10}, {30, 0}}};

ListLinePlot[conn, PlotStyle -> Dashing[Large]]


I am new to Mathematica. I want all the lines to be of the same color (say red). I tried different options, but they are not consistent with ListLinePlot. I also want to legend the whole structure as a single entity as I am having multiple structures in the same plot. Could somebody help me with this?

• Lots of ways to do what you want, e.g. Flatten[conn, 1] or Join@@conn in ListLinePlot. Then just use PlotLegends as desired.
– ciao
Mar 17, 2015 at 6:26

What you want might be satisfied by something as simple as

ListLinePlot[conn,
PlotStyle -> {{Red, Dashing[Large]}},
PlotLegends -> LineLegend[{"Entity"}]]


• Thank you so much. I'm getting the PlotStyle but I'm getting the following error everytime I use PlotLegend: ListLinePlot::optx: Unknown option PlotLegends in ListLinePlot[{{{0,0},{10,0}},{{0,0},{10,10}},{{10,0},{10,10}},{{10,0},{20,0}},{{10,10},{20,0}},{{10,10},{20,10}},{{20,0},{20,10}},{{20,0},{30,0}},{{20,10},{30,0}}},PlotStyle->{{RGBColor[1,0,0],Dashing[Large]}},PlotLegends->LineLegend[{Entity}]]. >>
– Indu
Mar 19, 2015 at 4:58
• @Indu. What version of Mathematica are you using? PlotLegends and LineLegend became available in V9.0. Mar 19, 2015 at 13:56
• I'm using V8.0 Is there a way to solve this problem in this version?
– Indu
Mar 23, 2015 at 3:09
• In V8 there is a Plot Legends package you can load with Needs. It's not as capable or as easy to use as the current PlotLegends option, but I think it can do what are you are looking for. I don't have V8 available, so I can't produce a V8 validated answer to your question. Here are two references that should help: guide; tutorial. Mar 23, 2015 at 15:03

Not sure if I understand your question, but here's my approach:

ListLinePlot[conn
, PlotStyle ->
{
{Red, Dashing[{3, 3}/100]}
, {Red, Dashing[Tiny]}
}
, Frame -> True
, PlotLegends -> Automatic]