Re: Multiple Line coloring and Dashing in ListPlot

*To*: mathgroup at smc.vnet.net*Subject*: [mg131433] Re: Multiple Line coloring and Dashing in ListPlot*From*: Bill Rowe <readnews at sbcglobal.net>*Date*: Sat, 6 Jul 2013 05:02:06 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*Delivered-to*: l-mathgroup@wolfram.com*Delivered-to*: mathgroup-outx@smc.vnet.net*Delivered-to*: mathgroup-newsendx@smc.vnet.net

On 7/3/13 at 5:01 AM, graser at gmail.com (graser) wrote: >I have a question about the coloring and dashing lines in listplot. >For example, Let's say there is a multiple data set like data = >Table[RandomReal[{2 i, 2 i + 1}, {20}], {i, 9}]; >I want to plot them in listplot or listloglogplot with all different >color and all different dashing with (joined -> True). How can I do >it automatically or minimum option? Here is an example of a list plot which has different dashing and different colors data = Table[RandomReal[{2 i, 2 i + 1}, {20}], {i, 3}]; ListPlot[data, Joined -> True, PlotStyle -> {{Red, Dashing[.01]}, {Green, Dashing[.015]}, {Blue, Dashing[.02]}}, Frame -> True] Here, I have reduce the number of lines to be plotted for clarity. You could replace the specific hard coded plot styles with a list generated using Table, i.e., something like styles=Table[{Hue[1/n],Dashing[5 n/1000]},{n,3}]; data = Table[RandomReal[{2 i, 2 i + 1}, {20}], {i, 3}]; ListPlot[data, Joined -> True, PlotStyle -> styles, Frame -> True] >The default number of coloring >in mathematica (I am in still 8) is 4. after that, it repeat same >color. Actually, version 8 does not repeat the same color after 4. But the first color and 5 color with the default colors are quite similar and difficult to distinguish. By default the first color is In[9]:= ColorData[1][1] Out[9]= RGBColor[0.2472,0.24,0.6] and the fifth color is: In[10]:= ColorData[1][5] Out[10]= RGBColor[0.24,0.353173,0.6] A way to avoid this issue is to use one of the named color schemes such as "Rainbow". See guide/ColorSchemes in the documentation center. But do note for this to be visually effective you need to map number of colors you want over the range of 0 to 1. In fact, the short snippet of code I show above for creating a list of styles using Table is fine for 3 colors but will not be visually effective for a large number of colors. There will be very little visual difference between Hue[1/n] and Hue[1/(n+1)] when n gets large.