3

I am trying to show a number of plots, which are indexed, and which all have the same marker type except when the error is under a certain threshold. Any plot on its own looks as expected, but when I put multiple plots under Show, the order in which the plots is listed affects the appearance, with markers seemingly being replaced by points. How can I keep them as markers?

Do[datatest[j] = Table[{k, j*k, 0.15*k}, {k, 10}], {j, 2}];(*Makes 2 tables with 10 points each*)

Do[dataFormat[j] = 
   Table[{{{datatest[j][[i, 1]], datatest[j][[i, 2]]}, 
   ErrorBar[datatest[j][[i, 3]]]}}, {i, 1, 
   Length[datatest[j]]}], {j,2}];(*puts in format for ErrorListPlot*)

colortable = {{1, Blue}, {2, Red}};(*one data set will be blue, the other red*)
markersize1 = 15; 
markersize2 = 30;
(*anything with an error bigger than 0.5 will get a bigger marker size (filtered below)*)

Do[datatestPlot[j] = 
   ErrorListPlot[dataFormat[j](*,PlotStyle\[Rule]{colortable[[j,2]]}*),
   Epilog -> {(Text[Style[Graphics`PlotMarkers[][[1, 1]], markersize2, 
   colortable[[j, 2]]], #] & /@ (Select[
   datatest[j], #[[3]] > 0.5 &][[All, {1, 
   2}]])), (Text[Style[Graphics`PlotMarkers[][[1, 1]], markersize1, 
   colortable[[j, 2]]], #] & /@ (Select[
   datatest[j], #[[3]] <= 0.5 &][[All, {1, 
   2}]])) }], {j, 2}];

Show[datatestPlot[1], datatestPlot[2]]
Show[datatestPlot[2], datatestPlot[1]]

Show12

Show21

alfwill
  • 33
  • 2

2 Answers2

3

you can only have one Epilog in a Show. Show takes the Epilog from the first plot and ignores the rest. One way to handle this is to store all the epilog graphics and join them in the show:

Do[
  datatestPlot[j] = 
   ErrorListPlot[dataFormat[j](*,PlotStyle\[Rule]{colortable[[j,2]]}*)];
  ep[j] = {(Text[
        Style[Graphics`PlotMarkers[][[1, 1]], markersize2, 
         colortable[[j, 2]]], #] & /@ (Select[
         datatest[j], #[[3]] > 0.5 &][[All, {1, 2}]])), (Text[
        Style[Graphics`PlotMarkers[][[1, 1]], markersize1, 
         colortable[[j, 2]]], #] & /@ (Select[
         datatest[j], #[[3]] <= 0.5 &][[All, {1, 2}]]))}, {j, 2}];

Show[datatestPlot[1], datatestPlot[2], Epilog -> Join[ep[1], ep[2]]]

enter image description here

If you wanted each plot to have its own epilog you can join them in Show something like this (using your original code):

Show[#, Epilog -> ((Epilog /. AbsoluteOptions[#] ) & /@ #)] &@
 Table[datatestPlot[i], {i, 2}]

same plot

george2079
  • 38,913
  • 1
  • 43
  • 110
0

You can also do:

ErrorListPlot[Join @@ dataFormat /@ {1, 2}, 
 Epilog -> 
  Table[{(Text[
        Style[Graphics`PlotMarkers[][[1, 1]], markersize2, 
         colortable[[j, 2]]], #] & /@ (Select[
         datatest[j], #[[3]] > 0.5 &][[All, {1, 2}]])), (Text[
        Style[Graphics`PlotMarkers[][[1, 1]], markersize1, 
         colortable[[j, 2]]], #] & /@ (Select[
         datatest[j], #[[3]] <= 0.5 &][[All, {1, 2}]]))}, {j, 2}]]

Mathematica graphics

kglr
  • 394,356
  • 18
  • 477
  • 896