{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "15574dcc",
   "metadata": {},
   "source": [
    "# Load the packages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2bb2341c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "%matplotlib inline\n",
    "\n",
    "plt.style.use(\"ggplot\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd447c79",
   "metadata": {},
   "source": [
    "# Load the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec12a98a",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('F:/compare_DL/compare/YRB_KGE.csv')\n",
    "data\n",
    "base = data['base']\n",
    "catch = data['catchment_LSTM']\n",
    "river= data['River_LSTM']\n",
    "multi = data['Multi_LSTM']\n",
    "wada= data['catchment_DPL']\n",
    "darya = data['River_DPL']\n",
    "hama = data['Multiscale_DPL']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd432f1a",
   "metadata": {},
   "source": [
    "# plot_KGE box"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d7aa3bd6",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "arrs = [wada,darya,hama,base, catch,river,multi]\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(10, 6), dpi= 500)\n",
    "\n",
    "\n",
    "bp = ax.boxplot(\n",
    "    x=arrs,\n",
    "    patch_artist=True,  \n",
    "    notch=True,  \n",
    "    vert=True  \n",
    ")\n",
    "\n",
    "\n",
    "colors = [\"green\", \"yellow\",\"orange\",\"blue\",\"pink\",\"brown\",\"red\"]\n",
    "for patch, color in zip(bp[\"boxes\"], colors):\n",
    "    # set_facecolor: 设置箱体内部颜色\n",
    "    # set_edgecolor: 设置箱体边框颜色\n",
    "    # set_color: 设置箱体内部和边框的颜色\n",
    "    patch.set_facecolor(color)\n",
    "\n",
    "# 设置须线的形状，大小，颜色\n",
    "for whisker in bp[\"whiskers\"]:\n",
    "    whisker.set(\n",
    "        color=\"red\",\n",
    "        linestyle=\"dashed\",\n",
    "        linewidth=1.5\n",
    "    )\n",
    "\n",
    "# 设置须线帽檐(caps)的样式\n",
    "for cap in bp[\"caps\"]:\n",
    "    cap.set(\n",
    "        color=\"blue\",\n",
    "        linewidth=2.5\n",
    "    )\n",
    "\n",
    "# 设置中位数的样式\n",
    "for median in bp[\"medians\"]:\n",
    "    median.set(\n",
    "        color=\"black\",\n",
    "        linewidth=2.0\n",
    "    )\n",
    "\n",
    "# 设置极值点的样式，超出帽檐的点就是极值点\n",
    "for flier in bp[\"fliers\"]:\n",
    "    flier.set(\n",
    "        marker=\"o\",\n",
    "        markersize=5,\n",
    "        markerfacecolor=\"red\",\n",
    "        alpha=0.3\n",
    "    )\n",
    "\n",
    "    \n",
    "# 设置y轴标签和标题\n",
    "bwith = 1 #边框宽度设置为2\n",
    "ax = plt.gca()#获取边框\n",
    "ax.spines['top'].set_color('black')  # 设置上‘脊梁’为红色\n",
    "ax.spines['right'].set_color('black')  # 设置上‘脊梁’为无色\n",
    "ax.spines['bottom'].set_color('black')  # 设置上‘脊梁’为红色\n",
    "ax.spines['left'].set_color('black')\n",
    "ax.spines['bottom'].set_linewidth(bwith)\n",
    "ax.spines['left'].set_linewidth(bwith)\n",
    "ax.spines['top'].set_linewidth(bwith)\n",
    "ax.spines['right'].set_linewidth(bwith)\n",
    "#bar_plot.axhline(y=0, color= 'green', linewidth=2,)\n",
    "ax.set_ylim(0,0.9)\n",
    "plt.yticks(fontname=\"Times New Roman\", fontsize=20,color='black')\n",
    "ax.set_xticklabels(['Catchment','River','Multiscale','Base','Catchment','River','Multiscale'], fontdict={\"family\": \"Times New Roman\", \"size\": 19, 'color':'black'})\n",
    "plt.ylabel('KGE', fontdict={\"family\": \"Times New Roman\", \"size\": 20, 'color':'black'})\n",
    "plt.savefig(\"yellow_KGE-BOX.jpg\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a4582c3a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
