4
$\begingroup$

I am sure that this is rather trivial, but still I cannot find a solution. If there is already a solution here or in Mathematica's help browser, just mention the link.

testE = {{0.727694, -10.0477}, {1.02897, -10.045}, {1.32329, \
-10.0419}, {1.63384, -10.0384}, {1.93279, -10.0345}, {2.23407, \
-10.0308}, {2.53534, -10.0267}, {2.8343, -10.0232}};

testD = {{0.723059, -10.0713}, {1.02202, -10.0681}, {1.31866, \
-10.0646}, {1.62457, -10.0602}, {1.92816, -10.057}, {2.22711, \
-10.0522}, {2.53071, -10.0475}, {2.82966, -10.0421}};

testC = {{0.720742, -10.0878 }, {1.02202, -10.0843} ,
   {1.31866, -10.08} , {1.6292, -10.0767 }, {1.92352, -10.0728} ,
   {2.22943, -10.0687} , {2.53071, -10.0654 }, {2.83198, -10.0611}};

testB = {{0.71898, -10.1098 }, {1.01353, -10.1072 }, {1.31736, \
-10.1041 }, {1.61886, -10.1004 },
   {1.92037, -10.0965 }, {2.22188, -10.0925 },
   {2.53034, -10.0878 }, {2.82489, -10.0839}} ;

testA = {{0.709702, -10.1503}, {1.01121, -10.1474},
   {1.30808, -10.1443 }, {1.60959, -10.1406 },
   {1.91805, -10.1369 }, {2.21724, -10.1333 },
   {2.52107, -10.1286}, {2.82489, -10.1239 }};

ListPlot[{testA, testB, testC, testD, testE}, Frame -> True, 
 PlotRange -> {{0.499, 3}, {-10.16, -10.01}}, 
 PlotStyle -> {Red, Blue, Orange, Magenta, Green}, 
 PlotLegends -> {"testA", "testB", "testC", "testD", "testE"}, 
 ImageSize -> 600, Joined -> True, Mesh -> All]

I take

enter image description here

I wanted the color of the points to match the color of the respective line. I can do this by superposition but I am sure there is sth quicker.

$\endgroup$
  • $\begingroup$ I just fount sth: ListPlot[{testA, testB, testC, testD, testE}, Frame -> True, PlotRange -> {{0.499, 3}, {-10.16, -10.01}}, PlotStyle -> {Red, Blue, Orange, Magenta, Green}, PlotLegends -> {"testA", "testB", "testC", "testD", "testE"}, ImageSize -> 600, Joined -> True, Mesh -> All, PlotMarkers -> Automatic] But still I want to keep the circles. $\endgroup$ – Dimitris Sep 18 '15 at 14:20
  • $\begingroup$ Related: mathematica.stackexchange.com/q/92118/28 $\endgroup$ – Alexey Popkov Sep 19 '15 at 6:25
5
$\begingroup$

You could use use the PlotMarkers option together with your list of custom colors.

In passing, I would also suggest that you use PlotRangePadding rather than setting a PlotRange explicitly.

customcolors = {Red, Blue, Orange, Magenta, Green};

ListPlot[{testA, testB, testC, testD, testE},
 Joined -> True, PlotMarkers -> customcolors, 
 PlotStyle -> customcolors,
 PlotRangePadding -> Scaled[0.1],
 Frame -> True, Axes -> False,
 PlotLegends -> {"testA", "testB", "testC", "testD", "testE"}
]

Mathematica graphics

$\endgroup$
5
$\begingroup$

Yet another option is to use ListLinePlot. Note the two sets of curly braces around the PlotMarkers specification.

ListLinePlot[{testA, testB, testC, testD, testE}, Frame -> True, 
 PlotRange -> {{0.499, 3}, {-10.16, -10.01}}, 
 PlotStyle -> {Red, Blue, Orange, Magenta, Green}, 
 PlotLegends -> {"testA", "testB", "testC", "testD", "testE"}, 
 ImageSize -> 600, Mesh -> All, 
 PlotMarkers -> {{"\[FilledCircle]", Large}}]

enter image description here

$\endgroup$
3
$\begingroup$

One approach is to generate the plot twice (joined and not) and combine:

Show[ListPlot[{testA, testB, testC, testD, testE}, Frame -> True, 
     PlotRange -> {{0.499, 3}, {-10.16, -10.01}}, 
        PlotStyle -> {Red, Blue, Orange, Magenta, Green}, 
           PlotLegends -> #[[2]], ImageSize -> 600, 
           Joined -> #[[1]]] & /@ {{True, {"testA", "testB", "testC", 
                                 "testD", "testE"}}, {False, {}}}]

enter image description here

Another, probably better, way is to specify both Joined and PlotMarkers->Automatic

I'd be interested to know if this can be done with Mesh.

$\endgroup$
  • $\begingroup$ Thanks for the reply. As I said I could have worked superposing the graphs (of course not so elegantly like you:-)!). I am also wondering if it can be done by Mesh. $\endgroup$ – Dimitris Sep 18 '15 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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