1
$\begingroup$
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?

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

2 Answers 2

2
$\begingroup$

What you want might be satisfied by something as simple as

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

plot

$\endgroup$
4
  • $\begingroup$ 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}]]. >> $\endgroup$
    – Indu
    Mar 19, 2015 at 4:58
  • $\begingroup$ @Indu. What version of Mathematica are you using? PlotLegends and LineLegend became available in V9.0. $\endgroup$
    – m_goldberg
    Mar 19, 2015 at 13:56
  • $\begingroup$ I'm using V8.0 Is there a way to solve this problem in this version? $\endgroup$
    – Indu
    Mar 23, 2015 at 3:09
  • $\begingroup$ 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. $\endgroup$
    – m_goldberg
    Mar 23, 2015 at 15:03
0
$\begingroup$

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]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.