5
$\begingroup$

Choosing the "Monochrome" theme surprisingly (bug?) adds plot markers to ListLinePlot. I would like to turn this off globally. (Specifically, I want to set $PlotTheme to "Monochrome" but have each ListLinePlot with no plot markers -- unless explicitly requested for an individual plot.)

I am looking for a global setting, not plot by plot.

$\endgroup$
4
$\begingroup$

You can use the following global settings:

$PlotTheme = "Monochrome";
SetOptions[ListLinePlot, Mesh -> 0];

Now the plot markers are gone:

ListLinePlot[Range@10]

enter image description here

To restore the default settings:

$PlotTheme = Automatic;
SetOptions[ListLinePlot, Mesh -> None];
$\endgroup$
  • $\begingroup$ I'm wondering why the right choice is Mesh->0 instead of PlotMarkers->None. (I see that your suggestion works; I don't understand why the alternative does not.) $\endgroup$ – Alan Jun 19 '17 at 14:52
  • $\begingroup$ It's "unusual behaviour" as rcollyer already remarked $\endgroup$ – eldo Jun 19 '17 at 16:24
  • $\begingroup$ Aha; at least surprising and possibly (?) buggy. Thanks! $\endgroup$ – Alan Jun 19 '17 at 17:04
  • $\begingroup$ In version 12, this no longer works. $\endgroup$ – Alan Aug 19 at 12:23
7
$\begingroup$

It is definitely not a bug. There is only so much that you can do with dashing, so plot markers are useful for making monochrome curves distinguishable.

As rcollyer points out in a comment, the most straightforward way to get rid of the plot markers is to add that option along with PlotTheme:

ListLinePlot[{
  Prime[Range[10]],
  Fibonacci[Range[10]],
  Range[10]
  }, PlotTheme -> "Monochrome", PlotMarkers -> None]

Mathematica graphics

Another option would be to create your own plot theme and use the setting given by Eldo to set the default plot theme to this.

As MichaelE2 showed here, and others elsewhere, there is a function called Charting`ResolvePlotTheme that will tell you exactly what the settings for a particular plot theme are.

style = Charting`ResolvePlotTheme["Monochrome", ListLinePlot];
ListLinePlot[{
  Prime[Range[10]],
  Fibonacci[Range[10]],
  Range[10]
  }, Sequence @@ style]

Mathemetica graphics

We can override options by prepending changes to style:

ListLinePlot[{
  Prime[Range[10]],
  Fibonacci[Range[10]],
  Range[10]
  }, Sequence @@ Prepend[style, PlotMarkers -> None]]

Mathematica graphics

In other words, Prepend[style, PlotMarkers -> None] could be made its own plot theme and be used as the default plot theme.

$\endgroup$
  • 1
    $\begingroup$ Instead of pulling the entire set of theme options using Charting`ResolvePlotTheme why don't you just use PlotMarkers -> None plus the theme? $\endgroup$ – rcollyer Jun 19 '17 at 13:53
  • $\begingroup$ @rcollyer Thank you, good point. I reframed the answer and included this. $\endgroup$ – C. E. Jun 19 '17 at 14:25
  • 1
    $\begingroup$ I think you left off in the middle of the edit ... :) Per eldo's answer, you could also use SetOptions to set PlotMarkers -> None which would have the same effect. $\endgroup$ – rcollyer Jun 19 '17 at 14:27
  • $\begingroup$ @rcollyer That's what the half-done paragraph was going to be about, but then it turned out that setting PlotMarkers -> None has no effect, which is probably why Eldo didn't do that. I removed that paragraph now. $\endgroup$ – C. E. Jun 19 '17 at 15:13
  • $\begingroup$ Ah, good point. I don't know if that would be considered a bug; it's definitely unusual behavior, though. $\endgroup$ – rcollyer Jun 19 '17 at 15:31
3
$\begingroup$

You can also use the option MeshStyle -> None:

SetOptions[ListLinePlot, MeshStyle -> None];
ListLinePlot[{Prime[Range[10]], Fibonacci[Range[10]], Range[10]}, 
   PlotTheme -> "Monochrome"]

Mathematica graphics

Or, create a custom PlotTheme modifying the "Monochrome" theme by removing the PlotMarkers following the method in this answer by Mr.Wizard's:

Themes`AddThemeRules["myTheme",
  DeleteCases[Charting`ResolvePlotTheme["Monochrome", ListLinePlot], 
   Rule[PlotMarkers, _]]];

ListLinePlot[{ Prime[Range[10]], Fibonacci[Range[10]], Range[10]}, 
 PlotTheme -> "myTheme"]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Aw, gosh, I was just going to do the DeleteCases[] plot theme thing...+1 $\endgroup$ – Michael E2 Jun 20 '17 at 0:13
  • $\begingroup$ @Michael, it took me a while to find Mr.Wizard's post to get this in:) Thank you for the vote. $\endgroup$ – kglr Jun 20 '17 at 0:19
  • $\begingroup$ Using SetOptions to change the MeshStyle no longer works. (Mma12 on Win 10.) $\endgroup$ – Alan Aug 19 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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