From 84f474d92ce69b3517248f1c6cd2fd7e0ae7b37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Sat, 27 Nov 2021 13:46:38 +1300 Subject: [PATCH] Load plt before setting rcParams and remove unneeded fontsize=14 --- 05_support_vector_machines.ipynb | 42 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/05_support_vector_machines.ipynb b/05_support_vector_machines.ipynb index bcb9d7f..3b08d58 100644 --- a/05_support_vector_machines.ipynb +++ b/05_support_vector_machines.ipynb @@ -86,11 +86,13 @@ "metadata": {}, "outputs": [], "source": [ - "import matplotlib as mpl\n", + "import matplotlib.pyplot as plt\n", "\n", - "mpl.rc('font', size=12)\n", - "mpl.rc('axes', labelsize=14, titlesize=14)\n", - "mpl.rc('legend', fontsize=14)" + "plt.rc('font', size=12)\n", + "plt.rc('axes', labelsize=14, titlesize=14)\n", + "plt.rc('legend', fontsize=14)\n", + "plt.rc('xtick',labelsize=10)\n", + "plt.rc('ytick',labelsize=10)" ] }, { @@ -287,13 +289,13 @@ "plt.text(0.3, 1.0, \"Impossible!\", color=\"red\", fontsize=18)\n", "plt.xlabel(\"Petal length\")\n", "plt.ylabel(\"Petal width\")\n", - "plt.annotate(\"Outlier\",\n", - " xy=(X_outliers[0][0], X_outliers[0][1]),\n", - " xytext=(2.5, 1.7),\n", - " ha=\"center\",\n", - " arrowprops=dict(facecolor='black', shrink=0.1),\n", - " fontsize=14,\n", - " )\n", + "plt.annotate(\n", + " \"Outlier\",\n", + " xy=(X_outliers[0][0], X_outliers[0][1]),\n", + " xytext=(2.5, 1.7),\n", + " ha=\"center\",\n", + " arrowprops=dict(facecolor='black', shrink=0.1),\n", + ")\n", "plt.axis([0, 5.5, 0, 2])\n", "plt.grid()\n", "\n", @@ -302,13 +304,13 @@ "plt.plot(Xo2[:, 0][yo2==0], Xo2[:, 1][yo2==0], \"yo\")\n", "plot_svc_decision_boundary(svm_clf2, 0, 5.5)\n", "plt.xlabel(\"Petal length\")\n", - "plt.annotate(\"Outlier\",\n", - " xy=(X_outliers[1][0], X_outliers[1][1]),\n", - " xytext=(3.2, 0.08),\n", - " ha=\"center\",\n", - " arrowprops=dict(facecolor='black', shrink=0.1),\n", - " fontsize=14,\n", - " )\n", + "plt.annotate(\n", + " \"Outlier\",\n", + " xy=(X_outliers[1][0], X_outliers[1][1]),\n", + " xytext=(3.2, 0.08),\n", + " ha=\"center\",\n", + " arrowprops=dict(facecolor='black', shrink=0.1),\n", + ")\n", "plt.axis([0, 5.5, 0, 2])\n", "plt.grid()\n", "\n", @@ -879,8 +881,8 @@ " if ylabel:\n", " plt.ylabel(\"$s$\", rotation=0, labelpad=5)\n", " plt.legend()\n", - " plt.text(1.02, -1.6, \"Margin\", ha=\"left\", va=\"center\",\n", - " color=\"k\", fontsize=14)\n", + " plt.text(1.02, -1.6, \"Margin\", ha=\"left\", va=\"center\", color=\"k\")\n", + "\n", " plt.annotate(\n", " '', xy=(-half_margin, -1.6), xytext=(half_margin, -1.6),\n", " arrowprops={'ec': 'k', 'arrowstyle': '<->', 'linewidth': 1.5}\n",