I have two lists of 2D data I would like to plot on a plane. These lists are of the same length n and are position-correlated to each other.

I need these lists to have two different colors, but share the same symbol for elements at position i in both lists.

For example, in the following image, the points with the same label should share the same symbol.

enter image description here

I have been struggling with ListPlot without success.


Is it possible to have two plot legends? One for the color and another for the symbol?


1 Answer 1


You can plot the datasets separately and combine them with Show:

pts1 = RandomReal[1, {10, 2}];
pts2 = RandomReal[1, {10, 2}];

pl = Show[
  List /@ pts1,
  PlotStyle -> ColorData[97, 1],
  PlotMarkers -> plotMarkers
  List /@ pts2,
  PlotStyle -> ColorData[97, 2],
  PlotMarkers -> plotMarkers


I used letters for plot markers. You can set PlotMarkers to Automatic to get the default shape. Also have a look here for other options.

For legends, you could do something like this:

legend1 = PointLegend[
  {ColorData[97, 1], ColorData[97, 2]},
  {"Data A", "Data B"}

legend2 = PointLegend[
  ConstantArray[ColorData[97, 1], 10],
  LegendMarkers -> plotMarkers

  Show[pl, ImageSize -> 400],

Multiple legends

I'm using Row here, you might be needing a different approach to the layout depending on how you want to lay them out.

  • $\begingroup$ How could I have a legend for both color and markers with this solution? $\endgroup$ May 5, 2020 at 15:43
  • 1
    $\begingroup$ @GuillermoOliver See my update. $\endgroup$
    – C. E.
    May 5, 2020 at 15:57
  • $\begingroup$ Thank you very much! $\endgroup$ May 5, 2020 at 16:00
  • 1
    $\begingroup$ As an alternative, legends can be inserted and placed in the desired position, one per plot, using PlotLegends. No need to use Row, using Show to visualize both plots would be enough. $\endgroup$ May 5, 2020 at 17:00

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.