1
$\begingroup$

I'm wondering, that is it possible in mathematica to associate plot legends with plot markers. For example let's say we have a Legended datas. Is it possible, to use the same marker for the data if the legend is a certain string? Example:

plots = Table[Symbol["plot" <> ToString@i], {i, 1, 2}];
Rsquared = {{0.1, 0.2}, {0.3, 0.4}}
filteredLength = {{100, 200}, {300, 400}}
filteredName = {{"foo", "bar"}, {"bar", "foo"}}
data = Legended[{{#, #2}}, #3] & @@@ (Join @@ 
     Thread /@ Transpose[{filteredLength, Rsquared, filteredName}]);
data = Partition[data, 2]

Do[plots[[i]] = 
  ListPlot[data[[i]], Joined -> False, AxesOrigin -> {0, 0}, 
   PlotRange -> All, GridLines -> Automatic, Frame -> True, 
   FrameStyle -> Directive[11], 
   GridLinesStyle -> Directive[Gray, Dashed], 
   FrameTicksStyle -> Directive[14], PlotMarkers -> Automatic];
 Print[plots[[i]]], {i, 1, 2}]

The thing i want, that if the "foo" appears as a legend, it has to be associated with a certain plot marker, on every plot.

If you know how to solve it, that would be awesome.

$\endgroup$

1 Answer 1

2
$\begingroup$

Sort input data by legend labels:

Do[plots[[i]] = ListPlot[SortBy[data[[i]], Last], 
   Joined -> False, AxesOrigin -> {0, 0},
   PlotRange -> All, GridLines -> Automatic, 
   Frame -> True, FrameStyle -> Directive[11], 
   GridLinesStyle -> Directive[Gray, Dashed], 
   FrameTicksStyle -> Directive[14], 
   PlotMarkers -> {Automatic, 14}], {i, 1, 2}]

Row[Show[#, ImageSize -> 300] & /@ plots, Spacer[10]]

enter image description here

$\endgroup$

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.