felipekitamura commited on
Commit
39f357f
·
verified ·
1 Parent(s): 72de3b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -22,7 +22,7 @@ def plot_reduced_data(reduced_data, labels, title):
22
  plt.figure(figsize=(10, 8))
23
  plt.scatter(reduced_data[:, 0], reduced_data[:, 1], alpha=0.6)
24
  for i, label in enumerate(labels):
25
- plt.annotate(label, (reduced_data[i, 0], reduced_data[i, 1]))
26
  plt.title(title)
27
  # Data for the arrow 1
28
  start_point = (reduced_data[0, 0], reduced_data[0, 1]) # Starting point of the arrow
@@ -30,15 +30,15 @@ def plot_reduced_data(reduced_data, labels, title):
30
 
31
  # Adding an arrow 1
32
  plt.annotate('', xy=end_point, xytext=start_point,
33
- arrowprops=dict(arrowstyle="->", color='green', lw=2))
34
 
35
  # Data for the arrow 2
36
- start_point = (reduced_data[2, 0] + reduced_data[0, 0] - reduced_data[1, 0], reduced_data[2, 1] + reduced_data[0, 1] - reduced_data[1, 1]) # Starting point of the arrow
37
- end_point = (reduced_data[2, 0], reduced_data[2, 1]) # Ending point of the arrow
38
 
39
  # Adding an arrow 2
40
  plt.annotate('', xy=end_point, xytext=start_point,
41
- arrowprops=dict(arrowstyle="->", color='green', lw=2))
42
 
43
  plt.xlabel('Component 1')
44
  plt.ylabel('Component 2')
 
22
  plt.figure(figsize=(10, 8))
23
  plt.scatter(reduced_data[:, 0], reduced_data[:, 1], alpha=0.6)
24
  for i, label in enumerate(labels):
25
+ plt.annotate(label, (reduced_data[i, 0], reduced_data[i, 1]), size=10)
26
  plt.title(title)
27
  # Data for the arrow 1
28
  start_point = (reduced_data[0, 0], reduced_data[0, 1]) # Starting point of the arrow
 
30
 
31
  # Adding an arrow 1
32
  plt.annotate('', xy=end_point, xytext=start_point,
33
+ arrowprops=dict(arrowstyle="->", color='green', lw=3))
34
 
35
  # Data for the arrow 2
36
+ end_point = (reduced_data[2, 0] - (reduced_data[0, 0] - reduced_data[1, 0]), reduced_data[2, 1] - (reduced_data[0, 1] - reduced_data[1, 1])) # Starting point of the arrow
37
+ start_point = (reduced_data[2, 0], reduced_data[2, 1]) # Ending point of the arrow
38
 
39
  # Adding an arrow 2
40
  plt.annotate('', xy=end_point, xytext=start_point,
41
+ arrowprops=dict(arrowstyle="->", color='green', lw=3))
42
 
43
  plt.xlabel('Component 1')
44
  plt.ylabel('Component 2')