Skip to content

Commit b25babd

Browse files
Made graphs look better
1 parent 243bdb1 commit b25babd

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

examples/plot_classifier.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,20 @@
2222
X_0 = X_test[y_pred == 0]
2323
X_1 = X_test[y_pred == 1]
2424

25-
ax0 = plt.scatter(X_0[:, 0], X_0[:, 1], c='crimson', s=30)
26-
ax1 = plt.scatter(X_1[:, 0], X_1[:, 1], c='deepskyblue', s=30)
2725

26+
p0 = plt.scatter(0, 0, c='red', s=100)
27+
p1 = plt.scatter(1, 1, c='blue', s=100)
28+
29+
ax0 = plt.scatter(X_0[:, 0], X_0[:, 1], c='crimson', s=50)
30+
ax1 = plt.scatter(X_1[:, 0], X_1[:, 1], c='deepskyblue', s=50)
31+
32+
leg = plt.legend([p0, p1, ax0, ax1],
33+
['Point 0', 'Point 1', 'Class 0', 'Class 1'],
34+
loc='upper left', fancybox=True, scatterpoints=1)
35+
leg.get_frame().set_alpha(0.5)
36+
37+
plt.xlabel('Feature 1')
38+
plt.ylabel('Feature 2')
39+
plt.xlim([-.5, 1.5])
2840

29-
plt.legend([ax0, ax1], ['Class 0', 'Class 1'])
3041
plt.show()

examples/plot_transformer.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99
from skltemplate import TemplateTransformer
1010
from matplotlib import pyplot as plt
1111

12-
X = np.arange(50).reshape(-1, 1)
12+
X = np.arange(50, dtype=np.float).reshape(-1, 1)
13+
X /= 50
1314
estimator = TemplateTransformer()
1415
X_transformed = estimator.fit_transform(X)
1516

16-
plt.plot(X.flatten()/X.max(), label='Original Data')
17-
plt.plot(X_transformed.flatten()/X_transformed.max(), label='Transformed Data')
18-
plt.title('Scaled plots of original and transformed data')
17+
plt.plot(X.flatten(), label='Original Data')
18+
plt.plot(X_transformed.flatten(), label='Transformed Data')
19+
plt.title('Plots of original and transformed data')
1920

2021
plt.legend(loc='best')
22+
plt.grid(True)
23+
plt.xlabel('Index')
24+
plt.ylabel('Value of Data')
25+
2126
plt.show()

0 commit comments

Comments
 (0)