# How to add PlotMarkers Only For One Set Of Data in ListPlot

I have two sets of data:

x1 = Range[0, 10, 0.1];
y1 = Sin[x1];

x2 = Range[0, 10, 0.1];
y2 = Cos[x2];


Now I want to make a ListPlot where the first set is represented as usual with dots and joined, but the second set should only be joined -> no dots.

I tryed:

ListPlot[
{
Transpose[{x1, y1}],
Transpose[{x2, y2}]},
PlotMarkers -> {{\[FilledCircle], 5}, None},
Joined -> True
]


...which does not work, as you can see:

• A workaround: ListPlot[{Transpose[{x1, y1}], Transpose[{x2, y2}]}, PlotMarkers -> {{\[FilledCircle], 5}, {\[FilledCircle], 0}}, Joined -> True] May 26, 2017 at 7:51
• Another workaround: ListLinePlot[{Transpose[{x1, y1}], Transpose[{x2, y2}]}, PlotMarkers -> {{"\[FilledCircle]", 5}, ""}]. May 26, 2017 at 7:57
• @J.M Thank you very much ! This is exactly what I was looking for ! :) May 26, 2017 at 9:42

The solutions suggested so far all use glyph-based plot markers which are known to be positioned imprecisely by Mathematica. Here is primitive-based approach that is efficient and produces a publication-quality figure (when exporting to vector graphics formats):

ListLinePlot[{Transpose[{x1, y1}], Transpose[{x2, y2}]},
PlotMarkers -> {{Graphics[{Disk[]}, PlotRangePadding -> 1], .03}, {Graphics[], 0}}]


Note that the above image is exported from Mathematica 8 as PNG and has artifacts due to the fact that the FrontEnd sticks everything to the screen pixel grid when rendering. Exporting as PDF produces a perfect-looking plot (below it is rendered by Adobe Acrobat 11):

Export["i.pdf", %] // SystemOpen


But if you really care about the performance (evaluation time, rendering speed, size of the produced vector file), the best what you can do is to construct your graphics from the primitives directly. In your particular case it is simple and straightforward:

Graphics[{{Blue, Line[#], Point[#]} &@Transpose[{x1, y1}],
{Red, Line[Transpose[{x2, y2}]]}}, Frame -> True, AspectRatio -> 1/GoldenRatio]


As a bonus you get explicit control over positioning of the graphical primitives. :)

Try the following: Here are your lists:

lst1 = Range[0, 10, 0.1] /. x_ /; Head[x] == Real -> {x, Sin[x]};
lst2 = Range[0, 10, 0.1] /. x_ /; Head[x] == Real -> {x, Cos[x]};


Show[{
ListPlot[lst1, PlotMarkers -> Automatic, Joined -> True,
PlotStyle -> Red],
ListLinePlot[lst2]
}]


returning the following:

Have fun!

• Thanks !...Have a look at J.M's comment. It's a bit faster. :) May 26, 2017 at 9:56
• But would you mind to explain how you create your lists ? This looks very interesting. May 26, 2017 at 9:57
• @DoHe Welcome. If you mean to teach me programming a bit, thank you. I know the method used by JM, however. That is the matter of a personal taste only. Now about creating lists. Have a look into the chapter 4 here: mathprogramming-intro.org/book/node326.html. You will find a detailed description. May 26, 2017 at 13:32