Message Boards Message Boards

0
|
6938 Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

PlotMarkers option messes up font sizes. How to get v9's default markers?

Posted 10 years ago

After upgrading to v10, I've had trouble getting plot markers to appear, even approximately, the same way they did in v9. The default markers were little blue dots in v9, in v10 they are huge blue dots. I followed examples provided by Mathematica using text values and eventually came up the code below, illustrating a curiosity.

Module[{d3, markers}, 
 d3 = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}};
 markers = {{"A", "B", "C"}, {"A",
    "\!\(\*StyleBox[\"B\",\nFontSize->10]\)", 
    "\!\(\*StyleBox[\"C\",\nFontSize->8]\)"}};
 Table[ListPlot[d3, PlotMarkers -> markers[[k]]], {k, 2}]]

Note: the above code looks a bit complicated as posted here, but originally the expression beginning with "markers" was written simply as markers = {{"A", "B", "C"}, {"A", "B", "C"}}; and then the second "B" was reduced in size twice (using command-minus on Mac), and the second "C" was reduced in size four times.

Whichever way you enter the code, the first chart shows As, Bs and Cs all the same size, as you would expect; but the second chart shows the As and Bs the same (to my eyes) size, and the Cs a bit smaller.

My original intention was to approximate small dots by using PlotMarkers->"x", replacing the x with a bullet of appropriate font size. Thus did I discover this curious behavior.

POSTED BY: James Stein
3 Replies

You have discovered an error which has already been fixed for a future version. GridLines->{Automatic, None} will remove the horizontal grid lines.

Module[{dates, vals, data, j, f, i, o}, 
 dates = Table[{2012, k, 1}, {k, 12}];
 vals = {1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1};
 data = Transpose[{dates, vals}];
 j = Joined -> False;
 f = Filling -> Axis;
 i = ImageSize -> {150, 93};
 o = Sequence[data, j, f, i];
 DateListPlot[o, GridLines -> {Automatic, None}, 
  PlotTheme -> "Classic"]]
POSTED BY: Tim Shedelbower
Posted 10 years ago

Thank you, Tim, this is helpful.

However, I observe that when PlotTheme -> "Classic" is used with DateListPlot, horizontal grid lines appear. Reading the documentation for PlotTheme, this surprised me -- once again, ListPlot and DateListPlot seem to behave differently in ways unrelated to the nature of the horizontal axis. It seems they do not share a common code base.

I discovered that PlotTheme -> {"Classic", "Frame"} will use the classic markers and also nix the horizontal grid lines.

Here's code to help folks visualize this:

Module[{dates, vals, data, j, f, i, o},
 dates = Table[{2012, k, 1}, {k, 12}];
 vals = {1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1};
 data = Transpose[{dates, vals}];
 j = Joined -> False;
 f = Filling -> Axis;
 i = ImageSize -> {150, 93};
 o = Sequence[data, j, f, i];
 Print[
  DateListPlot[o],
  DateListPlot[o, PlotTheme -> "Classic"],
  DateListPlot[o, PlotTheme -> {"Classic", "Frame"}]];
 o = Sequence[vals, j, f, i];
 Print[
  ListPlot[o],
  ListPlot[o, PlotTheme -> "Classic"],
  ListPlot[o, PlotTheme -> {"Classic", "Frame"}]]
 ]

The output:

enter image description here

POSTED BY: James Stein

James,

The point sizes in v10 adjust with the number of points. As the point quantity increases the point size decreases. The font size for "B" is 10 which is the default font size, so "A" and "B" are identical in size. v9 produces the same result except the font family is Times. Below are a few solutions you can try:

Module[{d3}, 
 d3 = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}};
 ListPlot[d3, 
  PlotMarkers -> {{"•", 20}, {"•", 15}, {"•", 10}}]]

Module[{d3}, 
 d3 = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}};
 ListPlot[d3, 
  PlotMarkers -> {Style["A", 10], Style["B", 8], Style["C", 6]}]]

Module[{d3}, 
 d3 = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}};
 ListPlot[d3, PlotTheme -> "PlotMarkers"]]

Module[{d3}, 
 d3 = {{1, 2, 3, 5, 8}, {2, 3, 6, 9, 10}, {4, 5, 7, 10, 12}};
 ListPlot[d3, PlotTheme -> "Classic"]]

The last example using PlotTheme->"Classic" will display v9 default markers.

Tim

POSTED BY: Tim Shedelbower
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract