Gradient color on a line plot

Hi,

I was wondering this about 2 years ago [http://old.nabble.com/Gradient-color-on-a-line-object-td25630375.html]

Just today, I have found a very simple way to do this in mpl.

x = np.linspace(0, 2*np.pi, 3600)

y = np.sin(x)

plt.scatter(x,y,c=range(len(x)), marker=’_’, s=1)

Setting the marker to underscore character and choosing a relatively low size value makes the line appear just like I wanted. (Provided, using lengthy data points)

Is this a very known trick? If not so, what is your favorite color gradient approach for a simple plot?

Cheers,

···


Gökhan

Gökhan,

This a great trick! Much simpler than digging around with line
segments and such. My old solution to this problem was so clunky and
slow I'm embarrassed to post it. Thanks so much for sharing this.
-paul

···

On Sat, Nov 5, 2011 at 9:39 PM, Gökhan Sever <gokhansever@...287...> wrote:

Hi,
I was wondering this about 2 years ago
[http://old.nabble.com/Gradient-color-on-a-line-object-td25630375.html]
Just today, I have found a very simple way to do this in mpl.
x = np.linspace(0, 2*np.pi, 3600)
y = np.sin(x)
plt.scatter(x,y,c=range(len(x)), marker='_', s=1)
Setting the marker to underscore character and choosing a relatively low
size value makes the line appear just like I wanted. (Provided, using
lengthy data points)
Is this a very known trick? If not so, what is your favorite color gradient
approach for a simple plot?
Cheers,
--
Gökhan

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users