From: John S. <jsalvati@u.washington.edu> - 2010-08-23 19:07:00
|
Hello, I have a plot with lots of curves on it (say 30), and I would like to have some way of distinguishing the curves from each other. Just plotting them works well for a few curves because they come out as different colors unless you specify otherwise, but if you do too many you start getting repeats is there a way to have matplotlib also vary the line style that it automatically assigns? Or perhaps someone has another way of distinguishing lots of curves? Best Regards, John |
From: Aman T. <ama...@gm...> - 2010-08-23 19:39:04
|
Hi John, Here is a simple way to do it. import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(111) colors = ('red','green','blue','yellow','orange') linestyles = ('-','--',':') linewidths = (0.5,2) y = np.random.randn(100,30) x = range(y.shape[0]) i = 0 for c in colors: for ls in linestyles: for lw in linewidths: ax.plot(x,y[:,i],c=c,ls=ls,lw=lw) i+=1 plt.show() On 10-08-23 03:06 PM, John Salvatier wrote: > Hello, > > I have a plot with lots of curves on it (say 30), and I would like to > have some way of distinguishing the curves from each other. Just > plotting them works well for a few curves because they come out as > different colors unless you specify otherwise, but if you do too many > you start getting repeats is there a way to have matplotlib also vary > the line style that it automatically assigns? Or perhaps someone has > another way of distinguishing lots of curves? > > Best Regards, > John > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: John S. <jsalvati@u.washington.edu> - 2010-08-23 20:22:26
|
Thanks! On Mon, Aug 23, 2010 at 12:38 PM, Aman Thakral <ama...@gm...>wrote: > Hi John, > > Here is a simple way to do it. > > import matplotlib.pyplot as plt > import numpy as np > fig = plt.figure() > ax = fig.add_subplot(111) > > colors = ('red','green','blue','yellow','orange') > linestyles = ('-','--',':') > linewidths = (0.5,2) > > y = np.random.randn(100,30) > x = range(y.shape[0]) > i = 0 > > for c in colors: > for ls in linestyles: > for lw in linewidths: > ax.plot(x,y[:,i],c=c,ls=ls,lw=lw) > i+=1 > plt.show() > > > > On 10-08-23 03:06 PM, John Salvatier wrote: > > Hello, > > I have a plot with lots of curves on it (say 30), and I would like to have > some way of distinguishing the curves from each other. Just plotting them > works well for a few curves because they come out as different colors unless > you specify otherwise, but if you do too many you start getting repeats is > there a way to have matplotlib also vary the line style that it > automatically assigns? Or perhaps someone has another way of distinguishing > lots of curves? > > Best Regards, > John > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > > > _______________________________________________ > Matplotlib-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > |
From: John S. <jsalvati@u.washington.edu> - 2010-08-23 21:11:36
|
By the way, I found that the following generator expression made things easy: def styles(): return ( {'c' : color, 'ls' : style, 'lw' : width} for color, style, width in itertools.product(colors, linestyles, linewidths)) then you can do something like for result, style in zip(results, styles()): pylab.plot(result[i], **style) On Mon, Aug 23, 2010 at 1:22 PM, John Salvatier <jsalvati@u.washington.edu>wrote: > Thanks! > > > On Mon, Aug 23, 2010 at 12:38 PM, Aman Thakral <ama...@gm...>wrote: > >> Hi John, >> >> Here is a simple way to do it. >> >> import matplotlib.pyplot as plt >> import numpy as np >> fig = plt.figure() >> ax = fig.add_subplot(111) >> >> colors = ('red','green','blue','yellow','orange') >> linestyles = ('-','--',':') >> linewidths = (0.5,2) >> >> y = np.random.randn(100,30) >> x = range(y.shape[0]) >> i = 0 >> >> for c in colors: >> for ls in linestyles: >> for lw in linewidths: >> ax.plot(x,y[:,i],c=c,ls=ls,lw=lw) >> i+=1 >> plt.show() >> >> >> >> On 10-08-23 03:06 PM, John Salvatier wrote: >> >> Hello, >> >> I have a plot with lots of curves on it (say 30), and I would like to have >> some way of distinguishing the curves from each other. Just plotting them >> works well for a few curves because they come out as different colors unless >> you specify otherwise, but if you do too many you start getting repeats is >> there a way to have matplotlib also vary the line style that it >> automatically assigns? Or perhaps someone has another way of distinguishing >> lots of curves? >> >> Best Regards, >> John >> >> >> ------------------------------------------------------------------------------ >> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program >> Be part of this innovative community and reach millions of netbook users >> worldwide. Take advantage of special opportunities to increase revenue and >> speed time-to-market. Join now, and jumpstart your future. >> http://p.sf.net/sfu/intel-atom-d2d >> >> >> _______________________________________________ >> Matplotlib-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> > |
From: Chloe L. <ch...@be...> - 2010-08-24 06:24:36
|
And if you have mutually prime numbers of colors, linestyles, widths, you can automatically generate more distinct lines than I can distinguish... If there's any wxcuse for treating them as a series, I replot when I know how many I have, and space the colors through a colorbar. &C Away from home, checking mail rarely. On Aug 23, 2010, at 2:11 PM, John Salvatier <jsalvati@u.washington.edu> wrote: > By the way, I found that the following generator expression made > things easy: > > def styles(): > return ( {'c' : color, 'ls' : style, 'lw' : width} for color, > style, width in itertools.product(colors, linestyles, linewidths)) > > then you can do something like > > for result, style in zip(results, styles()): > pylab.plot(result[i], **style) > > On Mon, Aug 23, 2010 at 1:22 PM, John Salvatier <jsalvati@u.washington.edu > > wrote: > Thanks! > > > On Mon, Aug 23, 2010 at 12:38 PM, Aman Thakral > <ama...@gm...> wrote: > Hi John, > > Here is a simple way to do it. > > import matplotlib.pyplot as plt > import numpy as np > fig = plt.figure() > ax = fig.add_subplot(111) > > colors = ('red','green','blue','yellow','orange') > linestyles = ('-','--',':') > linewidths = (0.5,2) > > y = np.random.randn(100,30) > x = range(y.shape[0]) > i = 0 > > for c in colors: > for ls in linestyles: > for lw in linewidths: > ax.plot(x,y[:,i],c=c,ls=ls,lw=lw) > i+=1 > plt.show() > > > > On 10-08-23 03:06 PM, John Salvatier wrote: >> Hello, >> >> I have a plot with lots of curves on it (say 30), and I would like >> to have some way of distinguishing the curves from each other. Just >> plotting them works well for a few curves because they come out as >> different colors unless you specify otherwise, but if you do too >> many you start getting repeats is there a way to have matplotlib >> also vary the line style that it automatically assigns? Or perhaps >> someone has another way of distinguishing lots of curves? >> >> Best Regards, >> John >> >> >> --- >> --- >> --- >> --------------------------------------------------------------------- >> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program >> Be part of this innovative community and reach millions of netbook >> users >> worldwide. Take advantage of special opportunities to increase >> revenue and >> speed time-to-market. Join now, and jumpstart your future. >> http://p.sf.net/sfu/intel-atom-d2d >> >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > > --- > --- > --- > --------------------------------------------------------------------- > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook > users > worldwide. Take advantage of special opportunities to increase > revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Justin M. <jn...@gm...> - 2010-08-23 19:28:13
|
Here are a couple of functions you might try, with a few colors and line styles I use: import itertools from pylab import * COLORS = ['#990033', '#0000FF', '#00FF00', '#F79E00', '#ff00ff', '#0080FF', '#FF0000', '#2D0668', '#2EB42E', '#ff6633', '#8000ff', '#666633', '#cc0077', '#099499', '#996633', '#000000'] def new_stylecolor_iter(): ## Use these to alternate markers, or use all the styles. ## Combine them into the call to 'itertools.product' and ## then add the appropriate kwargs to the call to 'plot' #markers = itertools.cycle(lines.Line2D.markers.keys()) #styles = itertools.cycle(lines.Line2D.lineStyles.keys()) ## alternate colors first, line styles second sc = itertools.product(['-', ':', '--', '-.'], COLORS) return sc def line_plot_alternate(): sc = new_stylecolor_iter() for i in xrange(0,40): style, color = sc.next() plot(xrange(0,20), randn(20), label=str(i), linewidth=3, linestyle=style, color=color) legend() if __name__ == "__main__": line_plot_alternate() show() On Mon, Aug 23, 2010 at 3:06 PM, John Salvatier <jsalvati@u.washington.edu>wrote: > Hello, > > I have a plot with lots of curves on it (say 30), and I would like to have > some way of distinguishing the curves from each other. Just plotting them > works well for a few curves because they come out as different colors unless > you specify otherwise, but if you do too many you start getting repeats is > there a way to have matplotlib also vary the line style that it > automatically assigns? Or perhaps someone has another way of distinguishing > lots of curves? > > Best Regards, > John > > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |