2
$\begingroup$

How can I remove plot markers at some data points?
For example, I want to remove one plot marker at the circled point leaving only one marker there.
I tried deleting the data points but this would also delete part of the lines which is not wanted.
It would be good if I can input the data points where the markers should be removed. Assume that I already know the coordinate (data points) of these to be removed markers.

enter image description here

    (*Load the package code*)
    package = 
      Import["http://raw.github.com/AlexeyPopkov/PolygonPlotMarkers/\
    master/PolygonPlotMarkers.m", "Text"];
    
    (*Install the package (existing file will be overwritten!)*)
    Export[FileNameJoin[{$UserBaseDirectory, "Applications", 
        "PolygonPlotMarkers.m"}], package, "Text"];
    Needs["PolygonPlotMarkers`"]

    data = {Table[{x, 1 + 2 x}, {x, 0, 5, 1}], 
       Table[{x, 1 + x}, {x, 0, 5, 1}]} ;
    markers = {"Circle", "ThreePointedStar"};
    colors = {Blue, Red};
    Graphics[Table[{colors[[i]], Line[data[[i]]], FaceForm[White], 
       EdgeForm[{colors[[i]], AbsoluteThickness[2], JoinForm["Miter"]}], 
       PolygonMarker[markers[[i]], Offset[7], data[[i]]]}, {i, 
       Length[data]}], AspectRatio -> 1/2, ImageSize -> 450, 
     Frame -> True]


My orginal problem:

I want to remove markers at these points keeping only one markers there. enter image description here

(*Load the package code*)
package = 
  Import["http://raw.github.com/AlexeyPopkov/PolygonPlotMarkers/\
master/PolygonPlotMarkers.m", "Text"];
    
    (*Install the package (existing file will be overwritten!)*)
    Export[FileNameJoin[{$UserBaseDirectory, "Applications", 
        "PolygonPlotMarkers.m"}], package, "Text"];
    Needs["PolygonPlotMarkers`"]
    
    data = Table[{x, BesselJ[k, x]}, {k, 0, 4}, {x, 0, 10, 0.5}];
    markers = {"Circle", "ThreePointedStar", "FourPointedStar", 
       "FivePointedStar", "Circle"};
    colors = {Blue, Red, Darker@Green, Darker@Yellow, Orange};
    Graphics[Table[{colors[[i]], Line[data[[i]]], FaceForm[White], 
       EdgeForm[{colors[[i]], AbsoluteThickness[1], JoinForm["Miter"]}], 
       PolygonMarker[markers[[i]], Offset[7], data[[i]]]}, {i, 
       Length[data]}], AspectRatio -> 1/2, ImageSize -> 450, 
     Frame -> True]
$\endgroup$
7
  • $\begingroup$ Have you Tried ListPlot!? it's easier to work with PolygonMarker resources.wolframcloud.com/FunctionRepository/resources/… $\endgroup$
    – nufaie
    Jun 25, 2022 at 13:01
  • $\begingroup$ @Alrubaie not yet, would it work if I want to remove some markers? $\endgroup$
    – hana
    Jun 25, 2022 at 13:17
  • $\begingroup$ it's better and easier handling PolygonMarker inside ListPlot function. Check the link!!! part: Create a tuned up Graphics marker in one step: In[4]:= mtps = ResourceFunction["PolygonMarker"][ "ThreePointedStar", {Offset[7], 0}, {EdgeForm[Red], FaceForm[None]}] $\endgroup$
    – nufaie
    Jun 25, 2022 at 13:24
  • $\begingroup$ @Alrubaie I read that link before and my code above is basically from there. But my main goal is to remove markers at some specific points. $\endgroup$
    – hana
    Jun 25, 2022 at 13:26
  • $\begingroup$ @Alrubaie I think you misunderstood my question. I want to remove markers at some points instead of changing to a different marker's types. $\endgroup$
    – hana
    Jun 25, 2022 at 14:01

1 Answer 1

3
$\begingroup$
data = {Table[{x, 1 + 2 x}, {x, 0, 5, 1}], 
   Table[{x, 1 + x}, {x, 0, 5, 1}]};

colors = {Blue, Red};

markers = MapThread[
 First @ ResourceFunction["PolygonMarker"][#, {Offset[7], 0}, {EdgeForm[#2], FaceForm[White]}]&,
 {{"Circle", "ThreePointedStar"}, colors}];

Graphics[Table[{colors[[i]], Line[data[[i]]], FaceForm[White], 
   EdgeForm[{colors[[i]], AbsoluteThickness[2], JoinForm["Miter"]}], 
   Translate[markers[[i]], #] & /@ If[i == 1, data[[i]], Rest[data[[i]]]]}, 
  {i, Length[data]}], 
 AspectRatio -> 1/2, ImageSize -> 450, Frame -> True]

enter image description here

$\endgroup$
6
  • $\begingroup$ Thanks, I got this error Syntax::sntxb: Expression cannot begin with "[PolygonMarker][#,{Offset[7],0},{EdgeForm[#2],FaceForm[White]}]". $\endgroup$
    – hana
    Jun 26, 2022 at 8:26
  • $\begingroup$ What would I modify if there is more than 2 overlapping markers at one place and in some places? $\endgroup$
    – hana
    Jun 26, 2022 at 8:28
  • $\begingroup$ The markers is giving me errors but I don't know what should it be like to modify it. $\endgroup$
    – hana
    Jun 26, 2022 at 11:05
  • $\begingroup$ I updated my question with my original problem which is a bit more complex. $\endgroup$
    – hana
    Jun 26, 2022 at 11:10
  • 2
    $\begingroup$ @kglr I've edited the answer to add what I think was a missing call to ResourceFunction that was causing the syntax error. Feel free to revert if I've misinterpreted. $\endgroup$
    – MarcoB
    Jun 26, 2022 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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