How to remove lines through the legend markers in ListPlot?












8












$begingroup$


I am drawing a plot with some legends. It seems the legend markers will always have lines through them since I have to use Joined->True for this plot. The legend markers also seem to be always larger than those in the plot. My question is, is it possible to get rid of those lines through the legend markers and also make the legend markers smaller? Besides, is there a way to remove the grey outlines around the legend markers?



enter image description here



The code I used for this plot is



ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True, 
PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
AbsoluteThickness[1]}},
PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
0.04}}, InterpolationOrder -> 1,
Frame -> {{True, False}, {True, False}},
PlotLegends ->
Placed[PointLegend[
Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
FontSize -> 9, ScriptMinSize -> 6],
Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9,
ScriptMinSize -> 6]}], {0.3, 0.8}], ImageSize -> 240]









share|improve this question











$endgroup$

















    8












    $begingroup$


    I am drawing a plot with some legends. It seems the legend markers will always have lines through them since I have to use Joined->True for this plot. The legend markers also seem to be always larger than those in the plot. My question is, is it possible to get rid of those lines through the legend markers and also make the legend markers smaller? Besides, is there a way to remove the grey outlines around the legend markers?



    enter image description here



    The code I used for this plot is



    ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True, 
    PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
    AbsoluteThickness[1]}},
    PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
    0.04}}, InterpolationOrder -> 1,
    Frame -> {{True, False}, {True, False}},
    PlotLegends ->
    Placed[PointLegend[
    Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
    FontSize -> 9, ScriptMinSize -> 6],
    Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9,
    ScriptMinSize -> 6]}], {0.3, 0.8}], ImageSize -> 240]









    share|improve this question











    $endgroup$















      8












      8








      8


      1



      $begingroup$


      I am drawing a plot with some legends. It seems the legend markers will always have lines through them since I have to use Joined->True for this plot. The legend markers also seem to be always larger than those in the plot. My question is, is it possible to get rid of those lines through the legend markers and also make the legend markers smaller? Besides, is there a way to remove the grey outlines around the legend markers?



      enter image description here



      The code I used for this plot is



      ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True, 
      PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
      AbsoluteThickness[1]}},
      PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
      0.04}}, InterpolationOrder -> 1,
      Frame -> {{True, False}, {True, False}},
      PlotLegends ->
      Placed[PointLegend[
      Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
      FontSize -> 9, ScriptMinSize -> 6],
      Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9,
      ScriptMinSize -> 6]}], {0.3, 0.8}], ImageSize -> 240]









      share|improve this question











      $endgroup$




      I am drawing a plot with some legends. It seems the legend markers will always have lines through them since I have to use Joined->True for this plot. The legend markers also seem to be always larger than those in the plot. My question is, is it possible to get rid of those lines through the legend markers and also make the legend markers smaller? Besides, is there a way to remove the grey outlines around the legend markers?



      enter image description here



      The code I used for this plot is



      ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True, 
      PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
      AbsoluteThickness[1]}},
      PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
      0.04}}, InterpolationOrder -> 1,
      Frame -> {{True, False}, {True, False}},
      PlotLegends ->
      Placed[PointLegend[
      Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
      FontSize -> 9, ScriptMinSize -> 6],
      Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9,
      ScriptMinSize -> 6]}], {0.3, 0.8}], ImageSize -> 240]






      plotting legending marker






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 1 at 0:11









      corey979

      20.9k64282




      20.9k64282










      asked Feb 28 at 23:06









      nanjunnanjun

      35819




      35819






















          4 Answers
          4






          active

          oldest

          votes


















          7












          $begingroup$

          Just add the options Joined -> False and BaseStyle -> EdgeForm to PointLegend in your code to get



          enter image description here



          If you don't like the red syntax highlighting of BaseStyle -> EdgeForm you can use Method -> { BaseStyle -> EdgeForm}.






          share|improve this answer









          $endgroup$





















            4












            $begingroup$

            Here is a work around.



            Show[ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
            PlotStyle -> {Blue, Red},
            PlotMarkers -> {{Graphics@{EdgeForm[None], Disk},
            0.04}, {Graphics@{EdgeForm[None], Rectangle}, 0.04}},
            Frame -> {{True, False}, {True, False}},
            PlotLegends ->
            Placed[
            PointLegend[
            Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
            FontSize -> 9, ScriptMinSize -> 6],
            Style["Series 2", FontFamily -> "Times New Roman",
            FontSize -> 9, ScriptMinSize -> 6]}], {0.3, 0.8}],
            ImageSize -> 240],
            ListLinePlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}},
            PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
            AbsoluteThickness[1]}}]]


            enter image description here






            share|improve this answer









            $endgroup$





















              4












              $begingroup$

              Define a standalone legend:



              legend = PointLegend[{Blue, Red},
              {Style["Series 1", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6],
              Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6]},
              LegendMarkers -> {{Graphics@{EdgeForm[None], Disk}, 0.04},
              {Graphics@{EdgeForm[None], Rectangle}, 0.04}}]


              enter image description here



              Unfortunately, simply adding PlotLegends -> Placed[legend, {0.3, 0.8}] doesn't work:



              ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
              Joined -> True,
              PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
              AbsoluteThickness[1]}},
              PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
              0.04}}, InterpolationOrder -> 1,
              Frame -> {{True, False}, {True, False}},
              PlotLegends -> Placed[legend, {0.3, 0.8}],
              ImageSize -> 240]


              enter image description here



              However, this approach with HoldForm is succesful:



              ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
              Joined -> True,
              PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
              AbsoluteThickness[1]}},
              PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
              0.04}}, InterpolationOrder -> 1,
              Frame -> {{True, False}, {True, False}},
              PlotLegends -> Placed[HoldForm@Evaluate@legend, {0.3, 0.8}],
              ImageSize -> 240]


              enter image description here



              Alternatively, Legended is a workaround:



              Legended[
              ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True,
              PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
              AbsoluteThickness[1]}},
              PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
              0.04}}, InterpolationOrder -> 1,
              Frame -> {{True, False}, {True, False}}, ImageSize -> 240],
              Placed[legend, {0.3, 0.8}]]



              same plot as above







              share|improve this answer











              $endgroup$





















                2












                $begingroup$

                This is just an answer for your last question. You can get rid of the border of your markers in the legend by specifying EdgeForm[None], e.g.:



                ListPlot[
                {{1,2,3,4,5}, (1/2) {1,2,3,4,5}},
                Joined->True,
                PlotStyle->{
                {Blue,Dashed,AbsoluteThickness[1]},
                {Red,Dashed,AbsoluteThickness[1]}
                },
                PlotMarkers->{
                {Graphics@{EdgeForm[None],Disk},0.04},
                {Graphics@{EdgeForm[None],Rectangle},0.04}
                },
                InterpolationOrder->1,
                Frame->{{True,False},{True,False}},
                PlotLegends->Placed[
                PointLegend[
                Automatic,
                {
                Style["Series 1",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6],
                Style["Series 2",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6]
                }
                ],
                {0.3,0.8}
                ],
                ImageSize->240
                ]


                enter image description here






                share|improve this answer









                $endgroup$













                  Your Answer





                  StackExchange.ifUsing("editor", function () {
                  return StackExchange.using("mathjaxEditing", function () {
                  StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                  StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
                  });
                  });
                  }, "mathjax-editing");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "387"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: false,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192392%2fhow-to-remove-lines-through-the-legend-markers-in-listplot%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  7












                  $begingroup$

                  Just add the options Joined -> False and BaseStyle -> EdgeForm to PointLegend in your code to get



                  enter image description here



                  If you don't like the red syntax highlighting of BaseStyle -> EdgeForm you can use Method -> { BaseStyle -> EdgeForm}.






                  share|improve this answer









                  $endgroup$


















                    7












                    $begingroup$

                    Just add the options Joined -> False and BaseStyle -> EdgeForm to PointLegend in your code to get



                    enter image description here



                    If you don't like the red syntax highlighting of BaseStyle -> EdgeForm you can use Method -> { BaseStyle -> EdgeForm}.






                    share|improve this answer









                    $endgroup$
















                      7












                      7








                      7





                      $begingroup$

                      Just add the options Joined -> False and BaseStyle -> EdgeForm to PointLegend in your code to get



                      enter image description here



                      If you don't like the red syntax highlighting of BaseStyle -> EdgeForm you can use Method -> { BaseStyle -> EdgeForm}.






                      share|improve this answer









                      $endgroup$



                      Just add the options Joined -> False and BaseStyle -> EdgeForm to PointLegend in your code to get



                      enter image description here



                      If you don't like the red syntax highlighting of BaseStyle -> EdgeForm you can use Method -> { BaseStyle -> EdgeForm}.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 1 at 0:15









                      kglrkglr

                      187k10203421




                      187k10203421























                          4












                          $begingroup$

                          Here is a work around.



                          Show[ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                          PlotStyle -> {Blue, Red},
                          PlotMarkers -> {{Graphics@{EdgeForm[None], Disk},
                          0.04}, {Graphics@{EdgeForm[None], Rectangle}, 0.04}},
                          Frame -> {{True, False}, {True, False}},
                          PlotLegends ->
                          Placed[
                          PointLegend[
                          Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
                          FontSize -> 9, ScriptMinSize -> 6],
                          Style["Series 2", FontFamily -> "Times New Roman",
                          FontSize -> 9, ScriptMinSize -> 6]}], {0.3, 0.8}],
                          ImageSize -> 240],
                          ListLinePlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}},
                          PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                          AbsoluteThickness[1]}}]]


                          enter image description here






                          share|improve this answer









                          $endgroup$


















                            4












                            $begingroup$

                            Here is a work around.



                            Show[ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                            PlotStyle -> {Blue, Red},
                            PlotMarkers -> {{Graphics@{EdgeForm[None], Disk},
                            0.04}, {Graphics@{EdgeForm[None], Rectangle}, 0.04}},
                            Frame -> {{True, False}, {True, False}},
                            PlotLegends ->
                            Placed[
                            PointLegend[
                            Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
                            FontSize -> 9, ScriptMinSize -> 6],
                            Style["Series 2", FontFamily -> "Times New Roman",
                            FontSize -> 9, ScriptMinSize -> 6]}], {0.3, 0.8}],
                            ImageSize -> 240],
                            ListLinePlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}},
                            PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                            AbsoluteThickness[1]}}]]


                            enter image description here






                            share|improve this answer









                            $endgroup$
















                              4












                              4








                              4





                              $begingroup$

                              Here is a work around.



                              Show[ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                              PlotStyle -> {Blue, Red},
                              PlotMarkers -> {{Graphics@{EdgeForm[None], Disk},
                              0.04}, {Graphics@{EdgeForm[None], Rectangle}, 0.04}},
                              Frame -> {{True, False}, {True, False}},
                              PlotLegends ->
                              Placed[
                              PointLegend[
                              Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
                              FontSize -> 9, ScriptMinSize -> 6],
                              Style["Series 2", FontFamily -> "Times New Roman",
                              FontSize -> 9, ScriptMinSize -> 6]}], {0.3, 0.8}],
                              ImageSize -> 240],
                              ListLinePlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}},
                              PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                              AbsoluteThickness[1]}}]]


                              enter image description here






                              share|improve this answer









                              $endgroup$



                              Here is a work around.



                              Show[ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                              PlotStyle -> {Blue, Red},
                              PlotMarkers -> {{Graphics@{EdgeForm[None], Disk},
                              0.04}, {Graphics@{EdgeForm[None], Rectangle}, 0.04}},
                              Frame -> {{True, False}, {True, False}},
                              PlotLegends ->
                              Placed[
                              PointLegend[
                              Automatic, {Style["Series 1", FontFamily -> "Times New Roman",
                              FontSize -> 9, ScriptMinSize -> 6],
                              Style["Series 2", FontFamily -> "Times New Roman",
                              FontSize -> 9, ScriptMinSize -> 6]}], {0.3, 0.8}],
                              ImageSize -> 240],
                              ListLinePlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}},
                              PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                              AbsoluteThickness[1]}}]]


                              enter image description here







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Mar 1 at 0:02









                              Okkes DulgerciOkkes Dulgerci

                              5,2271917




                              5,2271917























                                  4












                                  $begingroup$

                                  Define a standalone legend:



                                  legend = PointLegend[{Blue, Red},
                                  {Style["Series 1", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6],
                                  Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6]},
                                  LegendMarkers -> {{Graphics@{EdgeForm[None], Disk}, 0.04},
                                  {Graphics@{EdgeForm[None], Rectangle}, 0.04}}]


                                  enter image description here



                                  Unfortunately, simply adding PlotLegends -> Placed[legend, {0.3, 0.8}] doesn't work:



                                  ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                                  Joined -> True,
                                  PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                  AbsoluteThickness[1]}},
                                  PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                  0.04}}, InterpolationOrder -> 1,
                                  Frame -> {{True, False}, {True, False}},
                                  PlotLegends -> Placed[legend, {0.3, 0.8}],
                                  ImageSize -> 240]


                                  enter image description here



                                  However, this approach with HoldForm is succesful:



                                  ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                                  Joined -> True,
                                  PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                  AbsoluteThickness[1]}},
                                  PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                  0.04}}, InterpolationOrder -> 1,
                                  Frame -> {{True, False}, {True, False}},
                                  PlotLegends -> Placed[HoldForm@Evaluate@legend, {0.3, 0.8}],
                                  ImageSize -> 240]


                                  enter image description here



                                  Alternatively, Legended is a workaround:



                                  Legended[
                                  ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True,
                                  PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                  AbsoluteThickness[1]}},
                                  PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                  0.04}}, InterpolationOrder -> 1,
                                  Frame -> {{True, False}, {True, False}}, ImageSize -> 240],
                                  Placed[legend, {0.3, 0.8}]]



                                  same plot as above







                                  share|improve this answer











                                  $endgroup$


















                                    4












                                    $begingroup$

                                    Define a standalone legend:



                                    legend = PointLegend[{Blue, Red},
                                    {Style["Series 1", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6],
                                    Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6]},
                                    LegendMarkers -> {{Graphics@{EdgeForm[None], Disk}, 0.04},
                                    {Graphics@{EdgeForm[None], Rectangle}, 0.04}}]


                                    enter image description here



                                    Unfortunately, simply adding PlotLegends -> Placed[legend, {0.3, 0.8}] doesn't work:



                                    ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                                    Joined -> True,
                                    PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                    AbsoluteThickness[1]}},
                                    PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                    0.04}}, InterpolationOrder -> 1,
                                    Frame -> {{True, False}, {True, False}},
                                    PlotLegends -> Placed[legend, {0.3, 0.8}],
                                    ImageSize -> 240]


                                    enter image description here



                                    However, this approach with HoldForm is succesful:



                                    ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                                    Joined -> True,
                                    PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                    AbsoluteThickness[1]}},
                                    PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                    0.04}}, InterpolationOrder -> 1,
                                    Frame -> {{True, False}, {True, False}},
                                    PlotLegends -> Placed[HoldForm@Evaluate@legend, {0.3, 0.8}],
                                    ImageSize -> 240]


                                    enter image description here



                                    Alternatively, Legended is a workaround:



                                    Legended[
                                    ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True,
                                    PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                    AbsoluteThickness[1]}},
                                    PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                    0.04}}, InterpolationOrder -> 1,
                                    Frame -> {{True, False}, {True, False}}, ImageSize -> 240],
                                    Placed[legend, {0.3, 0.8}]]



                                    same plot as above







                                    share|improve this answer











                                    $endgroup$
















                                      4












                                      4








                                      4





                                      $begingroup$

                                      Define a standalone legend:



                                      legend = PointLegend[{Blue, Red},
                                      {Style["Series 1", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6],
                                      Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6]},
                                      LegendMarkers -> {{Graphics@{EdgeForm[None], Disk}, 0.04},
                                      {Graphics@{EdgeForm[None], Rectangle}, 0.04}}]


                                      enter image description here



                                      Unfortunately, simply adding PlotLegends -> Placed[legend, {0.3, 0.8}] doesn't work:



                                      ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                                      Joined -> True,
                                      PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                      AbsoluteThickness[1]}},
                                      PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                      0.04}}, InterpolationOrder -> 1,
                                      Frame -> {{True, False}, {True, False}},
                                      PlotLegends -> Placed[legend, {0.3, 0.8}],
                                      ImageSize -> 240]


                                      enter image description here



                                      However, this approach with HoldForm is succesful:



                                      ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                                      Joined -> True,
                                      PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                      AbsoluteThickness[1]}},
                                      PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                      0.04}}, InterpolationOrder -> 1,
                                      Frame -> {{True, False}, {True, False}},
                                      PlotLegends -> Placed[HoldForm@Evaluate@legend, {0.3, 0.8}],
                                      ImageSize -> 240]


                                      enter image description here



                                      Alternatively, Legended is a workaround:



                                      Legended[
                                      ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True,
                                      PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                      AbsoluteThickness[1]}},
                                      PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                      0.04}}, InterpolationOrder -> 1,
                                      Frame -> {{True, False}, {True, False}}, ImageSize -> 240],
                                      Placed[legend, {0.3, 0.8}]]



                                      same plot as above







                                      share|improve this answer











                                      $endgroup$



                                      Define a standalone legend:



                                      legend = PointLegend[{Blue, Red},
                                      {Style["Series 1", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6],
                                      Style["Series 2", FontFamily -> "Times New Roman", FontSize -> 9, ScriptMinSize -> 6]},
                                      LegendMarkers -> {{Graphics@{EdgeForm[None], Disk}, 0.04},
                                      {Graphics@{EdgeForm[None], Rectangle}, 0.04}}]


                                      enter image description here



                                      Unfortunately, simply adding PlotLegends -> Placed[legend, {0.3, 0.8}] doesn't work:



                                      ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                                      Joined -> True,
                                      PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                      AbsoluteThickness[1]}},
                                      PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                      0.04}}, InterpolationOrder -> 1,
                                      Frame -> {{True, False}, {True, False}},
                                      PlotLegends -> Placed[legend, {0.3, 0.8}],
                                      ImageSize -> 240]


                                      enter image description here



                                      However, this approach with HoldForm is succesful:



                                      ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, 
                                      Joined -> True,
                                      PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                      AbsoluteThickness[1]}},
                                      PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                      0.04}}, InterpolationOrder -> 1,
                                      Frame -> {{True, False}, {True, False}},
                                      PlotLegends -> Placed[HoldForm@Evaluate@legend, {0.3, 0.8}],
                                      ImageSize -> 240]


                                      enter image description here



                                      Alternatively, Legended is a workaround:



                                      Legended[
                                      ListPlot[{{1, 2, 3, 4, 5}, (1/2) {1, 2, 3, 4, 5}}, Joined -> True,
                                      PlotStyle -> {{Blue, Dashed, AbsoluteThickness[1]}, {Red, Dashed,
                                      AbsoluteThickness[1]}},
                                      PlotMarkers -> {{Graphics@{Disk}, 0.04}, {Graphics@{Rectangle},
                                      0.04}}, InterpolationOrder -> 1,
                                      Frame -> {{True, False}, {True, False}}, ImageSize -> 240],
                                      Placed[legend, {0.3, 0.8}]]



                                      same plot as above








                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 2 days ago

























                                      answered Mar 1 at 0:08









                                      corey979corey979

                                      20.9k64282




                                      20.9k64282























                                          2












                                          $begingroup$

                                          This is just an answer for your last question. You can get rid of the border of your markers in the legend by specifying EdgeForm[None], e.g.:



                                          ListPlot[
                                          {{1,2,3,4,5}, (1/2) {1,2,3,4,5}},
                                          Joined->True,
                                          PlotStyle->{
                                          {Blue,Dashed,AbsoluteThickness[1]},
                                          {Red,Dashed,AbsoluteThickness[1]}
                                          },
                                          PlotMarkers->{
                                          {Graphics@{EdgeForm[None],Disk},0.04},
                                          {Graphics@{EdgeForm[None],Rectangle},0.04}
                                          },
                                          InterpolationOrder->1,
                                          Frame->{{True,False},{True,False}},
                                          PlotLegends->Placed[
                                          PointLegend[
                                          Automatic,
                                          {
                                          Style["Series 1",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6],
                                          Style["Series 2",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6]
                                          }
                                          ],
                                          {0.3,0.8}
                                          ],
                                          ImageSize->240
                                          ]


                                          enter image description here






                                          share|improve this answer









                                          $endgroup$


















                                            2












                                            $begingroup$

                                            This is just an answer for your last question. You can get rid of the border of your markers in the legend by specifying EdgeForm[None], e.g.:



                                            ListPlot[
                                            {{1,2,3,4,5}, (1/2) {1,2,3,4,5}},
                                            Joined->True,
                                            PlotStyle->{
                                            {Blue,Dashed,AbsoluteThickness[1]},
                                            {Red,Dashed,AbsoluteThickness[1]}
                                            },
                                            PlotMarkers->{
                                            {Graphics@{EdgeForm[None],Disk},0.04},
                                            {Graphics@{EdgeForm[None],Rectangle},0.04}
                                            },
                                            InterpolationOrder->1,
                                            Frame->{{True,False},{True,False}},
                                            PlotLegends->Placed[
                                            PointLegend[
                                            Automatic,
                                            {
                                            Style["Series 1",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6],
                                            Style["Series 2",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6]
                                            }
                                            ],
                                            {0.3,0.8}
                                            ],
                                            ImageSize->240
                                            ]


                                            enter image description here






                                            share|improve this answer









                                            $endgroup$
















                                              2












                                              2








                                              2





                                              $begingroup$

                                              This is just an answer for your last question. You can get rid of the border of your markers in the legend by specifying EdgeForm[None], e.g.:



                                              ListPlot[
                                              {{1,2,3,4,5}, (1/2) {1,2,3,4,5}},
                                              Joined->True,
                                              PlotStyle->{
                                              {Blue,Dashed,AbsoluteThickness[1]},
                                              {Red,Dashed,AbsoluteThickness[1]}
                                              },
                                              PlotMarkers->{
                                              {Graphics@{EdgeForm[None],Disk},0.04},
                                              {Graphics@{EdgeForm[None],Rectangle},0.04}
                                              },
                                              InterpolationOrder->1,
                                              Frame->{{True,False},{True,False}},
                                              PlotLegends->Placed[
                                              PointLegend[
                                              Automatic,
                                              {
                                              Style["Series 1",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6],
                                              Style["Series 2",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6]
                                              }
                                              ],
                                              {0.3,0.8}
                                              ],
                                              ImageSize->240
                                              ]


                                              enter image description here






                                              share|improve this answer









                                              $endgroup$



                                              This is just an answer for your last question. You can get rid of the border of your markers in the legend by specifying EdgeForm[None], e.g.:



                                              ListPlot[
                                              {{1,2,3,4,5}, (1/2) {1,2,3,4,5}},
                                              Joined->True,
                                              PlotStyle->{
                                              {Blue,Dashed,AbsoluteThickness[1]},
                                              {Red,Dashed,AbsoluteThickness[1]}
                                              },
                                              PlotMarkers->{
                                              {Graphics@{EdgeForm[None],Disk},0.04},
                                              {Graphics@{EdgeForm[None],Rectangle},0.04}
                                              },
                                              InterpolationOrder->1,
                                              Frame->{{True,False},{True,False}},
                                              PlotLegends->Placed[
                                              PointLegend[
                                              Automatic,
                                              {
                                              Style["Series 1",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6],
                                              Style["Series 2",FontFamily->"Times New Roman",FontSize->9,ScriptMinSize->6]
                                              }
                                              ],
                                              {0.3,0.8}
                                              ],
                                              ImageSize->240
                                              ]


                                              enter image description here







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Feb 28 at 23:44









                                              Carl WollCarl Woll

                                              69.6k394180




                                              69.6k394180






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Mathematica Stack Exchange!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  Use MathJax to format equations. MathJax reference.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192392%2fhow-to-remove-lines-through-the-legend-markers-in-listplot%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  How to change which sound is reproduced for terminal bell?

                                                  Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                                                  Can I use Tabulator js library in my java Spring + Thymeleaf project?