Please, can someone help me? I've been digging the documentation, but I
can't find a way to do this.


Alessio Civ wrote:
> 
> Hi,
> 
> I'm trying to make a scatter plot of 2 variables using a thirds as filter
> to have different colors.
> 
> Let's say I have those data:
> 
> x=1,2,3,4
> y=2,3,4,5
> z=0,1,0,1
> 
> Then I want the values of x and y corresponding to those of z=0 to be of a
> color and those corresponding to z=1 to be of another color.
> 
> This is the code I manage to do until know:
> 
> 
> import xlrd
> import numpy as np
> import matplotlib.pyplot as plt
> 
> wb = xlrd.open_workbook('GBL2009.xls')
> sh = wb.sheet_by_index(0)
> 
> def column_pos():
>     first_row=sh.row_values(0)
>     net_p=""
>     for i in first_row:
>         if i=='net_price':
>             net_p=first_row.index(i) #In gets the column position
>     for i in first_row:
>         if i=='material':
>             mat_p=first_row.index(i) #In gets the column position
>     for i in first_row:
>         if i=='qty':
>             qty_p=first_row.index(i) #In gets the column position
>     print net_p,  mat_p,  qty_p
>     #filtering(net_p, mat_p, qty_p)
>     test(net_p, mat_p, qty_p)
>     
>         
> def test(net_p, mat_p, qty_p):
>     list=[]
>     for rownum in range(sh.nrows):
>         if sh.cell(rownum,mat_p).value in (96433890,  96433886):
>             list.append(sh.row_values(rownum))
> 
>     x=[]
>     y=[]
>     z=[]
>     for i in list:
>         x.append(i[qty_p])
>         y.append(i[net_p])
>         z.append(i[mat_p])
> 
>     fig = plt.figure(1, figsize=(5.5,5.5))
>     axScatter = plt.subplot(111)
> 
>     colors = ('r', 'g', 'b', 'k')
>     for c in colors:
>         axScatter.scatter(x, y,  c=c,  marker='s')
> 
>     plt.show()
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Scatter-Plot-with-different-colors-tp29887701p29926014.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to