diff --git a/module3/exo3/exercice.ipynb b/module3/exo3/exercice.ipynb index 2869398655ecdbe1dd1c15cc8f68478e7e9dfc63..b17100c1e25c8f0c88846840d39ab8e2946a2582 100644 --- a/module3/exo3/exercice.ipynb +++ b/module3/exo3/exercice.ipynb @@ -533,7 +533,6 @@ ], "source": [ "sorted_data.plot(title= \"Evolution des salaires et du prix du blé\")\n", - "print(graphique1)\n", "sorted_data.plot(subplots=True,title= [\"Evolution du prix du blé\", \"Evolution des salaires\"])" ] }, @@ -575,7 +574,7 @@ ], "source": [ "graphique1 = plt.figure()\n", - "ax = graphique1.add_subplot(111)\n", + "ax_1_1 = graphique1.add_subplot(111)\n", "plt.ylabel('Livres')\n", "sorted_data.plot(title= \"Evolution des salaires et du prix du blé\",ax=ax)\n" ] @@ -622,14 +621,14 @@ "x=list(raw_data[\"Year\"])\n", "y_wages=list(raw_data[\"Wages\"])\n", "y_wheat=list(raw_data[\"Wheat\"])\n", - "graphique1 = plt.figure()\n", - "ax = graphique1.add_subplot(111)\n", - "ax.set(xbound=[1550,1850],ybound=[0,100],ylabel=\"Shillings\",xlabel=\"Year\",Title=\"Evolution of wheat prices and wages\")\n", - "ax.xaxis.set_major_locator(plt.MultipleLocator(50))\n", - "ax.bar(x,y_wheat,width=5, color=\"black\",label=\"Wheat Price\")\n", - "ax.plot(x,y_wages,color=\"red\",label=\"Wages\")\n", - "ax.fill_between(x,y_wages,0,color=\"blue\")\n", - "ax.legend()\n", + "graphique2 = plt.figure()\n", + "ax_2_1 = graphique2.add_subplot(111)\n", + "ax_2_1.set(xbound=[1550,1850],ybound=[0,100],ylabel=\"Shillings\",xlabel=\"Year\",Title=\"Evolution of wheat prices and wages\")\n", + "ax_2_1.xaxis.set_major_locator(plt.MultipleLocator(50))\n", + "ax_2_1.bar(x,y_wheat,width=5, color=\"black\",label=\"Wheat Price\")\n", + "ax_2_1.plot(x,y_wages,color=\"red\",label=\"Wages\")\n", + "ax_2_1.fill_between(x,y_wages,0,color=\"blue\")\n", + "ax_2_1.legend()\n", " \n" ] }, @@ -678,15 +677,15 @@ "y_wages=list(raw_data[\"Wages\"])\n", "y_wheat=list(raw_data[\"Wheat\"])\n", "zero=[0 for i in x]\n", - "graphique2 = plt.figure()\n", - "ax1 = graphique2.add_subplot(111)\n", - "ax1.set(xbound=[1550,1850],ybound=[0,100],ylabel=\"Shillings\",xlabel=\"Year\",Title=\"Evolution of wheat prices and wages\")\n", - "ax1.xaxis.set_major_locator(plt.MultipleLocator(50))\n", - "ax1.plot(x,zero,color=\"black\",label=\"Wheat\")\n", - "ax1.plot(x,y_wages,color=\"red\",label=\"Wages\")\n", - "ax1.fill_between(x,y_wheat,0,color=\"black\",step=\"mid\",alpha=0.5)#alpha permet d'avoir un remplissage semi-transparent\n", - "ax1.fill_between(x,y_wages,0,color=\"blue\")\n", - "ax1.legend(loc='upper left')\n" + "graphique3 = plt.figure()\n", + "ax3_1 = graphique3.add_subplot(111)\n", + "ax3_1.set(xbound=[1550,1850],ybound=[0,100],ylabel=\"Shillings\",xlabel=\"Year\",Title=\"Evolution of wheat prices and wages\")\n", + "ax3_1.xaxis.set_major_locator(plt.MultipleLocator(50))\n", + "ax3_1.plot(x,zero,color=\"black\",label=\"Wheat\")\n", + "ax_3_1.plot(x,y_wages,color=\"red\",label=\"Wages\")\n", + "ax_3_1.fill_between(x,y_wheat,0,color=\"black\",step=\"mid\",alpha=0.5)#alpha permet d'avoir un remplissage semi-transparent\n", + "ax_3_1.fill_between(x,y_wages,0,color=\"blue\")\n", + "ax_3_1.legend(loc='upper left')\n" ] }, { @@ -727,22 +726,29 @@ } ], "source": [ - "graphique3 = plt.figure()\n", - "ax3 = graphique3.add_subplot(111)\n", - "ax3.set(xbound=[1550,1850],ybound=[0,100],ylabel=\"Wheat Price (shilling per 1/4 bushel)\",xlabel=\"Year\",Title=\"Evolution of wheat prices and wages\")\n", - "ax3.xaxis.set_major_locator(plt.MultipleLocator(50))\n", + "graphique4 = plt.figure()\n", + "ax_4_1 = graphique4.add_subplot(111)\n", + "ax_4_1.set(xbound=[1550,1850],ybound=[0,100],ylabel=\"Wheat Price (shilling per 1/4 bushel)\",xlabel=\"Year\",Title=\"Evolution of wheat prices and wages\")\n", + "ax_4_1.xaxis.set_major_locator(plt.MultipleLocator(50))\n", "\n", - "ax3.plot(x,zero,color=\"red\",label=\"Wages\")\n", - "ax3.plot(x,zero,color=\"black\",label=\"Wheat\")\n", + "ax_4_1.plot(x,zero,color=\"red\",label=\"Wages\")\n", + "ax_4_1.plot(x,zero,color=\"black\",label=\"Wheat\")\n", " \n", - "ax3.fill_between(x,y_wheat,0,color=\"black\",step=\"mid\",alpha=0.65)#alpha permet d'avoir un remplissage semi-transparent\n", + "ax_4_1.fill_between(x,y_wheat,0,color=\"black\",step=\"mid\",alpha=0.65)#alpha permet d'avoir un remplissage semi-transparent\n", "\n", - "ax4=ax3.twinx()\n", - "ax4.plot(x,y_wages,color=\"red\",label=\"Wages\")\n", - "ax4.fill_between(x,y_wages,0,color=\"blue\",alpha=0.25)\n", - "ax4.set_ylabel(\"Wages (shilling per week)\", color=\"red\")\n", - "ax4.tick_params(axis='y', labelcolor=\"red\")\n", - "ax3.legend(loc='upper left')\n" + "ax_4_2=ax_4_1.twinx()\n", + "ax_4_2.plot(x,y_wages,color=\"red\",label=\"Wages\")\n", + "ax_4_2.fill_between(x,y_wages,0,color=\"blue\",alpha=0.25)\n", + "ax_4_2.set_ylabel(\"Wages (shilling per week)\", color=\"red\")\n", + "ax_4_2.tick_params(axis='y', labelcolor=\"red\")\n", + "ax_4_1.legend(loc='upper left')\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Si j'essaie de mettre la meme échelle à droite et à gauche pour ne pas avoir de superposition des coubres, il y a un décalage qui apparait ! Il doit manquer une option quelque part !!" ] }, { @@ -750,7 +756,24 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "graphique5 = plt.figure()\n", + "ax_5_1 = graphique5.add_subplot(111)\n", + "ax_5_1.set(xbound=[1550,1850],ybound=[0,100],ylabel=\"Wheat Price (shilling per 1/4 bushel)\",xlabel=\"Year\",Title=\"Evolution of wheat prices and wages\")\n", + "ax_5_1.xaxis.set_major_locator(plt.MultipleLocator(50))\n", + "\n", + "ax_5_1.plot(x,zero,color=\"red\",label=\"Wages\")\n", + "ax_5_1.plot(x,zero,color=\"black\",label=\"Wheat\")\n", + " \n", + "ax_5_1.fill_between(x,y_wheat,0,color=\"black\",step=\"mid\",alpha=0.65)#alpha permet d'avoir un remplissage semi-transparent\n", + "\n", + "ax_5_2=ax_5_1.twinx()\n", + "ax_5_2.plot(x,y_wages,color=\"red\",label=\"Wages\")\n", + "ax_5_2.fill_between(x,y_wages,0,color=\"blue\",alpha=0.25)\n", + "ax_5_2.set_ylabel(\"Wages (shilling per week)\", color=\"red\")\n", + "ax_5_2.tick_params(axis='y', labelcolor=\"red\")\n", + "ax_5_1.legend(loc='upper left')" + ] } ], "metadata": {