Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to use ListPlot to plot some points. I would like the PlotMarkers to be open circles. I can use PlotMarkers -> Graphics[Circle[]], as in the following example, but the circles are too large. Is there a way that I can specify the size of open circles to use in PlotMarkers? Thanks for your time.

myData = {{0, 3.0}, {10, 3.1}, {20, 3.2}, {30, 3.0}, {40, 3.0}, {90, 3.0}};

ListPlot[myData, PlotRange -> {{-1, 101}, {2.9, 3.3}}, Joined -> True,
  Mesh -> Full, Frame -> True, PlotStyle -> Directive[Red, Thick], 
  PlotMarkers -> Graphics[{Red, Thick, Circle[]}]]

PlotMarkers

share|improve this question
2  
PlotMarkers -> Graphics[{Red, Thick, Circle[]},ImageSize->10] –  Mike Honeychurch Feb 27 '13 at 22:27
1  
Similar question: mathematica.stackexchange.com/questions/5770/… –  David Carraher Feb 28 '13 at 0:28
add comment

5 Answers

up vote 9 down vote accepted

PlotMarkers are rendered as insets to the graphics so you need to set a small image size in your graphics plot marker:

ListPlot[myData, PlotRange -> {{-1, 101}, {2.9, 3.3}}, Joined -> True,
  Mesh -> Full, Frame -> True, PlotStyle -> Directive[Red, Thick], 
 PlotMarkers -> Graphics[{Red, Thick, Circle[]}, ImageSize -> 10]]

enter image description here

Because plot markers are insets you may find that if you have a large number of points the graphic rendering is noticeably slow -- particular if the plot is made dynamic. In that case you can try and use primitives directly to get some speed improvements. This example hasn't quite worked out as planned because I've made an elipse rather than a circle for reasons not immediately clear (but probably obvious to someone else who might like to point out the error).

ListLinePlot[myData, PlotRange -> {{-1, 101}, {2.9, 3.3}}, 
 Frame -> True, PlotStyle -> Directive[Red, Thick], 
 Epilog -> {Red, Thick, Circle[#, Scaled[.01]] & /@ myData}]

enter image description here

Edit

it appears that AspectRatio is messing up the scaling but this can be fixed:

ListLinePlot[myData, PlotRange -> {{-1, 101}, {2.9, 3.3}}, 
 Frame -> True, PlotStyle -> Directive[Red, Thick], 
 Epilog -> {Red, Thick, 
   Disk[#, Scaled[{0.02, 0.02*GoldenRatio}]] & /@ myData}]

enter image description here

...some random shapes:

ListLinePlot[myData, PlotRange -> {{-1, 101}, {2.9, 3.3}}, 
 Frame -> True, PlotStyle -> Directive[Red, Thick], 
 Epilog -> {Red, Thick, 
   Polygon[{Scaled[{0.003, 0.01}, #], Scaled[{-0.03, 0.03}, #], 
       Scaled[{-0.03, -0.03}, #], Scaled[{0.02, -0.05}, #]}] & /@ 
    myData}]

enter image description here

...with the qualifier that you would go down this path if you have a large data set and plot markers (insets) are slowing things down.

share|improve this answer
add comment

What about the "Empty Circle" in the special characters menu. Go to Insert_Special Characters_Symbols to find it or type esc_eci_esc.

share|improve this answer
2  
Font based markers have alignment issues –  rm -rf Feb 28 '13 at 0:22
    
I agree with Nguyen - the best solution is to simply use: PlotMarkers -> "[EmptyCircle]" ... [EmptyCircle] with a backslash before ... site is dropping the backslash ... Works like a charm. Even better, you can adjust the size of the circle by simply selecting it with the mouse, and changing the font size. Same goes for changing the colour: just select the circle and change the colour to something that suits you. The end result is the neatest and shortest code. –  wolfies Apr 9 '13 at 9:23
add comment

I can't comment, so I'd just like to expand on the difference between Mike Honeychurch's and Nguyen Van Falk's answers. Using graphics (like Mike) is slow if you have many points on the graph. This is a reason to use mere characters (like Nguyen). However, as veteran "rm -rf" pointed out in the comments to Nguyen's post, there can be some minor alignment issues due to the way fonts are rendered which are not very easy to fix in an a robust way.

Therefore, the best idea is to use characters when you need to plot quickly, and use slow graphics when you need something beautiful. To choose a character, bring up the Special Characters panel from the Palette menu.

share|improve this answer
add comment

Often PlotMarkers may not align exactly the way you expect. An alternate to ListPlot is to construct the plot using Graphics primitives.

    myData = {{0, 3.0}, {10, 3.1}, {20, 3.2}, {30, 3.0}, {40, 3.0}, {90, 
        3.0}};

    Manipulate[
     Graphics[{{Blue, Line[myData]},
       {Red, GeometricTransformation[Circle[{0, 0}, Offset[{size, size}]],
          myData]}},
      PlotRange -> {{-1, 101}, {2.9, 3.3}}, Frame -> True, 
      PlotRangeClipping -> True, AspectRatio -> 1],
     {size, 5, 15}]

I first saw GeometricTransformation used for this purpose as an answer to a question on this site, but I can't seem to locate it now.

share|improve this answer
add comment

I repeatedly recommend using graphics primitives for the sake of performance, and in many cases simplicity or at least predictability. I therefore support Mike's use of Epilog. There is however a simpler method to render circles rather than ellipses: Offset. This also produces a fixed-size "point" which may or may not be desired.

myData = {{0, 3.0}, {10, 3.1}, {20, 3.2}, {30, 3.0}, {40, 3.0}, {90, 3.0}};

ListLinePlot[myData,
 PlotRange -> {{-1, 101}, {2.9, 3.3}},
 Frame -> True, PlotStyle -> Directive[Red, Thick],
 Epilog -> {Red, Thick, Circle[#, Offset @ 5] & /@ myData}
]

enter image description here

Offset also works within PlotMarkers if you prefer to use the canonical method:

PlotMarkers -> Graphics[{Red, Thick, Circle[{0, 0}, Offset @ 5]}]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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