|
From: Jonathan S. <js...@cf...> - 2012-10-02 17:01:07
|
Hi all, I'm trying to make a plot with several lines, each with a different grayscale color. I thought I could do something like clrs = ['0.125', '0.25', '0.375', '0.5', '0.625', '0.75', '0.875', '1.0'] and then either set the color cycle using clrs or just use the color=clrs[i] argument in a loop that draws the lines. This kind of works, but it seems that there's some autoscaling going on. If I use values ranging from 0 to 1, the curve with 0 doesn't show up at all (which I would expect) and the curve with 1 is black. If I use values ranging from 0.5 to 1, the curve with 0.5 doesn't show up and the curve with 1 is gray instead of black. What gives? How can I get a set of curves with gray values ranging from medium gray to black? As a simple demo if I do: import matplotlib.pyplot as plt import numpy as np import matplotlib.cm as cmap x = np.linspace(0,1.,num=10) y1 = 0.5*x y2 = 0.4*x fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(x,y1,color='0.5') ax.plot(x,y2,color='1.0') ax.legend(['y1','y2']) plt.show() I get a single visible line that is a sort of medium gray. Jon -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA js...@cf... 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ |