4
$\begingroup$

I have a particular plot I want make with the following features:

  • ListPlot with three separate lists.
  • Uses the monochrome plot theme.
  • Has a legend.
  • Has larger than default axis labels and values.

Here is the snippet of code I've tried

ListPlot[Table[Table[i*j, {i, 1, 100}], {j, 1, 3}], Frame -> True, 
  BaseStyle -> {FontSize -> 16}, 
  PlotTheme -> "Monochrome", 
  FrameLabel -> 
    {Style["Abscissa", FontSize -> 18], Style["Ordinate", FontSize -> 18]}, 
  PlotLegends -> 
    Placed[
      SwatchLegend[{"Set 1", "Set 2", "Set 3"}, LegendMarkerSize -> 16], 
      {0.25, 0.75}], 
  ImageSize -> Full]

My issues are:

When the code is evaluated as-is, it's clearly not in monochrome. However, the plot markers are changed from plain circles.

If you remove the BaseStyle option, the plot does become monochrome however the legend becomes useless.

So how do I build this plot completely in monochrome, with larger fonts, and a useful legend (ie, displays the plot shapes, not colors)

$\endgroup$

1 Answer 1

5
$\begingroup$

Replace BaseStyle with LabelStyle and SwatchLegend with LineLegend:

lp = ListPlot[Table[Table[i*j, {i, 1, 100}], {j, 1, 3}], Frame -> True, 
 LabelStyle -> {FontSize -> 16}, 
 PlotTheme -> "Monochrome", 
 FrameLabel -> {Style["Abscissa", FontSize -> 18], Style["Ordinate", FontSize -> 18]}, 
 PlotLegends -> Placed[LineLegend[{"Set 1", "Set 2", "Set 3"}, 
    LegendMarkerSize -> 16], {0.25, 0.75}], 
 ImageSize -> 700]

enter image description here

To re-size the markers in the legend, you can use

 MapAt[# /. Offset[x_] :> Offset[2 x] &, lp, {2}]

enter image description here

In order to use SwatchLegend we need to set the option value for LegendMarkers to the default markers used by ListPlot. The latter can be obtained using

pmarkers = PlotMarkers /. 
   Charting`ResolvePlotTheme["PlotMarkers", ListPlot];

Change the option PlotLegends -> LineLegend[...] above to

PlotLegends -> 
 Placed[SwatchLegend[{"Set 1", "Set 2", "Set 3"}, 
   LegendMarkerSize -> 16, LegendMarkers -> pmarkers], {0.25, 0.75}]

to get the first picture above and use the same post-processing to get the second picture.

$\endgroup$
1
  • $\begingroup$ Thank you so much! $\endgroup$
    – Denis
    Dec 28, 2019 at 3:29

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.