1
$\begingroup$

I'm creating a ListPlot where I plot many data sets simultaneously. Currently, my code that produces it is something like this:

ListPlot[alldat, PlotStyle -> "Rainbow", PlotLegends -> SwatchLegend["Rainbow", flist]]

Where alldat is my list of data sets, and flist is a list of their names (corresponding to alldat, so in the same order).

This produces this:

enter image description here

The important part I'm asking about is the legend, and the labeling colors. This graph only has 10 curves and already it's getting pretty hard for me to differentiate between some of them (I can do it but I have to squint and concentrate for a minute). I know that at some point I'm just going to crowd the plot so much it won't matter what color or pattern they are, but I'd like to go up to maybe 20 curves.

How can I plot them and label them clearly so I can tell them apart? Maybe only use 5 different colors, but 4 times of pattern or something (solid, dashed, dot dashed, dotted). I know I could list out all the things separately but I want something that will automatically work for a variable amount of curves.

Is there a clever way to do this?

$\endgroup$
3
  • 1
    $\begingroup$ Dots and dashes won't help you if you are using ListPlot and Joined->False as the default. See how some of your data series (e.g. that green one) have breaks in them? $\endgroup$
    – Verbeia
    Nov 17, 2014 at 1:42
  • $\begingroup$ Do you need to label all your data series? If your data represent for example the evolution of a field over time, then you may only need to label every (eg) 5th curve? You haven't said what it is you're plotting? You may be able to group related experiments by colour. $\endgroup$
    – dwa
    Nov 17, 2014 at 2:50
  • $\begingroup$ @Verbeia, right, good point. $\endgroup$ Nov 17, 2014 at 4:06

2 Answers 2

5
$\begingroup$

If it is to be printed and you have space (say, a page), then a grid can be effective, where each dataset is plotted in a highlight color over a monochromatic plot of all datasets:

maxmin = {Min /@ Transpose[data], Max /@ Transpose[data]};
background = 
  ListLinePlot[Join[maxmin, data], PlotStyle -> Directive[Thin, Gray],
    Filling -> {1 -> {2}}];
plots = MapThread[
   ListPlot[#, PlotStyle -> #2, AbsoluteOptions[background, PlotRange],
     PlotLabel -> "Dataset " <> ToString[#3]] &,
   {data, ColorData[97] /@ Range[Length@data], Range[Length@data]}];

GraphicsGrid[
 Partition[
  Show[
     background,
     #,
     Options[#]
     ] & /@ plots,
  4],
 ImageSize -> Full]

Mathematica graphics

In Mathematica, one can highlight each plot with something like TabView. You lose the ability to scan the relationships at a glance that I think you get with the grid view above, but the individual graphs can be inspected more easily.

TabView[Show[
    background,
    #,
    Options[#]
    ] & /@ plots]

Mathematica graphics

Basically I am suggesting that it is hard to look at a plot of a dozen or twenty graphs and be able to easily discern important information as well as suggesting one alternative presentation.

$\endgroup$
2
$\begingroup$

Assuming you really want solid lines for your data, I'd suggest something like the following.

ListLinePlot[fakedata, 
 PlotStyle -> (Flatten@
    Outer[Directive, {AbsoluteThickness[1.5], Dashing[0.02], 
      DotDashed, Dotted}, Take[ColorData[22, "ColorList"], 5]])]

enter image description here

For shorter data series in the data set, PlotMarkers can help if you truncate your colour palette.

ListLinePlot[fakedata,  PlotStyle -> Take[ColorData[22, "ColorList"], 5], 
 PlotMarkers -> Automatic ]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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