Skip to main content
opacity fix for legends: /q/128856/
Source Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_, opts___][in_: White, out_: Black, size_: 13] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], Opacity[1], out}], prim}, opts, ImageSize -> size] 

Shapes:

square = marker @ Rectangle[]; circle = marker @ Disk[]; diamond = marker @ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}]; triangle = marker[ Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}], AlignmentPoint -> {0, 1/Sqrt[3]} ]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4}, PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Magenta, Purple]}, PlotLegends -> Automatic ] 

enter image description hereenter image description here

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_, opts___][in_: White, out_: Black, size_: 13] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], prim}, opts, ImageSize -> size] 

Shapes:

square = marker @ Rectangle[]; circle = marker @ Disk[]; diamond = marker @ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}]; triangle = marker[ Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}], AlignmentPoint -> {0, 1/Sqrt[3]} ]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4}, PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Magenta, Purple]}, PlotLegends -> Automatic ] 

enter image description here

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_, opts___][in_: White, out_: Black, size_: 13] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], Opacity[1], out}], prim}, opts, ImageSize -> size] 

Shapes:

square = marker @ Rectangle[]; circle = marker @ Disk[]; diamond = marker @ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}]; triangle = marker[ Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}], AlignmentPoint -> {0, 1/Sqrt[3]} ]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4}, PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Magenta, Purple]}, PlotLegends -> Automatic ] 

enter image description here

correct mistake
Source Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_, opts___][out_opts___][in_: BlackWhite, in_out_: WhiteBlack, size_: 12]13] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], prim}, opts,  PlotRangePadding -> 0opts,  ImageSize -> size] 

Shapes:

square = marker @ Rectangle[]; circle = marker @ Disk[]; diamond = marker @ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}]; triangle = marker[ Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}], AlignmentPoint -> {0, 1/Sqrt[3]} ]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4},  PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Purpletriangle[Magenta, Magenta]Purple]}, PlotLegends -> Automatic ] 

enter image description hereenter image description here

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_, opts___][out_: Black, in_: White, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], prim}, opts,  PlotRangePadding -> 0,  ImageSize -> size] 

Shapes:

square = marker @ Rectangle[]; circle = marker @ Disk[]; diamond = marker @ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}]; triangle = marker[ Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}], AlignmentPoint -> {0, 1/Sqrt[3]} ]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4}, PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Purple, Magenta]} ] 

enter image description here

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_, opts___][in_: White, out_: Black, size_: 13] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], prim}, opts, ImageSize -> size] 

Shapes:

square = marker @ Rectangle[]; circle = marker @ Disk[]; diamond = marker @ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}]; triangle = marker[ Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}], AlignmentPoint -> {0, 1/Sqrt[3]} ]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4},  PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Magenta, Purple]}, PlotLegends -> Automatic ] 

enter image description here

Include Alexey's fix for triangle centering
Source Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_][out_marker[prim_, opts___][out_: Black, in_: White, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], prim}, opts, PlotRangePadding -> 0, ImageSize -> size] 

Shapes:

square  = marker[Rectangle[]];marker @ Rectangle[]; circle  = marker[Disk[]];marker @ Disk[]; diamond = marker[Rectangle[]~Rotate~(45marker \[Degree])@ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}]; triangle =   marker[Polygon[marker[ Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]];],   AlignmentPoint -> {0, 1/Sqrt[3]} ]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4}, PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Magentatriangle[Purple, Purple]Magenta]} ] 

enter image description hereenter image description here

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_][out_: Black, in_: White, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], prim}, PlotRangePadding -> 0, ImageSize -> size] 

Shapes:

square = marker[Rectangle[]]; circle = marker[Disk[]]; diamond = marker[Rectangle[]~Rotate~(45 \[Degree])]; triangle = marker[Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4}, PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Magenta, Purple]} ] 

enter image description here

\[FilledSquare] is a font glyph and you cannot color parts of it.

I believe you need to draw your markers with Graphics primitives. For example:

square[in_, out_: Black, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], Rectangle[]}, PlotRangePadding -> 0, ImageSize -> size] data = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}}; ListLinePlot[data, PlotMarkers -> square /@ {Red, Green, Blue} ] 

enter image description here

ListLinePlot[data, PlotMarkers -> square @@@ {{Yellow, Red}, {White, Blue}, {Black, Pink}} ] 

enter image description here


Update: proof that this method can easily be used for markers of arbitrary shape.

Generic marker function:

marker[prim_, opts___][out_: Black, in_: White, size_: 12] := Graphics[{in, EdgeForm[{AbsoluteThickness[2], out}], prim}, opts, PlotRangePadding -> 0, ImageSize -> size] 

Shapes:

square  = marker @ Rectangle[]; circle  = marker @ Disk[]; diamond = marker @ Polygon[{{0, 1}, {1, 2}, {2, 1}, {1, 0}}]; triangle =   marker[ Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}],   AlignmentPoint -> {0, 1/Sqrt[3]} ]; 

Plot:

SeedRandom[12] ListLinePlot[ Accumulate /@ RandomReal[3, {4, 10}] {1, 2, 3, 4}, PlotMarkers -> {square[], circle[Yellow], diamond[Brown, Pink], triangle[Purple, Magenta]} ] 

enter image description here

added 820 characters in body
Source Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k
Loading
added 193 characters in body
Source Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k
Loading
Fixed size instead of 12
Source Link
Öskå
  • 8.6k
  • 4
  • 33
  • 53
Loading
Source Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k
Loading