I have the following question in python : I have 7 lists(can be even a simple row or column vector) each one with same number of elements .For example :
a = [x1,x2,....xn] where xi is a float
b= [y1,y2,.....yn] where yi is a float
...........
g = [z1,z2,... zn] where zi is a float
What I need to do is :
First to find all possible combinations of these seven lists without repetitions (I know there is itertools.combinations) in groups of two (I must find 21 possible combinations). For example (a,b) , (a,c), (a,d)....
Second ,once I get all these combinations I can run a sort of for cycle to plot all these 21 graps in 2D (plot(a,b), plot(a,c),...plot(f,g)). I was thinking something like list of lists, but I am wondering if there is something ready in some library or even easier. Thanks!
EDIT
@FHTMitchell
Look at this simple example, I only get one chart if plt.show() is not indented
mydata = np.array([[1.4,2.5,3.7],[4.34,5.92,6.234],[2.34,5.12,62.234],[44.34,90.92,23.234],[65.34,44.92,16.234]])
col1 = mydata[:,0]
col2= mydata[:,1]
col3 = mydata[:,2]
for pair in itertools.combinations((col1,col2,col3), 2):
print(list(pair))
fig, ax = plt.subplots()
ax.scatter(pair[0], pair[1])
plt.show()
Try using seaborn library.
I'd import those arrays into a pandas dataframe and then plot those using PairGrid. The most simple one is generated like this:
sns.pairplot(df)
This will give you a scatter plot matrix of all possible combinations between variables:
The plot matrix
https://seaborn.pydata.org/generated/seaborn.pairplot.html#seaborn.pairplot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With