Reputation: 772
I have a data frame like this:
clusters = pd.concat(l,keys=range(len(l)))
clusters =
latitude longitude
0 872 11.1248 2.5902
873 11.1246 2.5908
874 11.1230 2.5944
875 11.1228 2.5943
876 11.1157 2.5903
... ... ... ...
3 76 11.1610 2.7873
1226 11.1024 2.7498
1227 11.1027 2.7500
1228 11.1072 2.7568
1229 11.1076 2.7563
Where 0,1,2,3 (total 4 clusters) shows my clusters.
I want to plot all clusters in a one loop (with a loop maybe) in the following way:
0
in red and clusters 1,2,3
in grey1
in red and clusters 0,2,3
in grey2
in red and clusters 1,0,3
in grey3
in red and clusters 1,2,0
in greySomething like
x_test = ready_couples.loc[0].longitude
y_test = ready_couples.loc[0].latitude
x_all = ready_couples.longitude
y_all = ready_couples.latitude
plt.style.use('seaborn-darkgrid')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
for k in ready_couples:
plt.scatter(x_all, y_all, marker='.', color='grey', linewidth=1, alpha=0.4)
plt.scatter(x_test, y_test, marker='.', color='orange', linewidth=4, alpha=0.7)
Upvotes: 0
Views: 58
Reputation: 488
You can try something like this:
import pandas as pd
import matplotlib.pyplot as plt
clusters = pd.DataFrame({
'mi': [0, 0, 0, 1, 1, 1],
'i': [1, 2, 3, 4, 5, 6],
'latitude': [1, 2, 4, 4, 5, 5],
'longitude': [1, 4, 5, 4, 5, 5]
})
# you can reset index if needed
# clusters = clusters.reset_index()
clusters = clusters.set_index(['mi'])
plt.plot(clusters.loc[index_in_red,'latitude'], clusters.loc[index_in_red,'longitude'], 'r')
plt.plot(clusters.loc[clusters.index != index_in_red,'latitude'], clusters.loc[clusters.index != index_in_red,'longitude'], 'grey')
plt.show()
Upvotes: 1