Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 7, 2024
1 parent 30db975 commit 837eda3
Showing 1 changed file with 128 additions and 65 deletions.
193 changes: 128 additions & 65 deletions notebooks/Usage example of psychrochart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7862,13 +7862,13 @@
],
"source": [
"print(\"** Customized chart style (from `ashrae`), Zoom in [15, 35]:\")\n",
"chart_ashrae_style = PsychroChart.create('ashrae')\n",
"chart_ashrae_style = PsychroChart.create(\"ashrae\")\n",
"\n",
"# zoom in\n",
"chart_ashrae_style.config.figure.title = None\n",
"chart_ashrae_style.config.limits.range_temp_c = (15, 35)\n",
"chart_ashrae_style.config.limits.range_humidity_g_kg = (0, 25)\n",
"chart_ashrae_style.config.saturation.color = 'darkorange'\n",
"chart_ashrae_style.config.saturation.color = \"darkorange\"\n",
"chart_ashrae_style.config.saturation.linewidth = 4\n",
"\n",
"svg_ashrae = chart_ashrae_style.make_svg()\n",
Expand Down Expand Up @@ -11989,7 +11989,7 @@
],
"source": [
"print(\"** Preconfigured chart style: `ashrae_ip`:\")\n",
"chart_ashrae_ip = PsychroChart.create('ashrae_ip', use_unit_system_si=False)\n",
"chart_ashrae_ip = PsychroChart.create(\"ashrae_ip\", use_unit_system_si=False)\n",
"svg_ashrae_ip = chart_ashrae_ip.make_svg()\n",
"HTML(svg_ashrae_ip)"
]
Expand Down Expand Up @@ -12672,21 +12672,28 @@
"custom_chart.config.chart_params.with_constant_wet_temp = False\n",
"custom_chart.config.chart_params.with_constant_h = False\n",
"\n",
"# plot to generate matplotlib objects, and continue customizing the chart 🌈 \n",
"# plot to generate matplotlib objects, and continue customizing the chart 🌈\n",
"custom_chart.plot()\n",
"# show names of objects in plot\n",
"print(\"** Each object in plot has a readable name to access it for fine-grain customizations:\")\n",
"print(\n",
" \"** Each object in plot has a readable name to access it for fine-grain customizations:\"\n",
")\n",
"print(custom_chart.artists.render_tree())\n",
"\n",
"# apply customizations for single objects in plot\n",
"custom_chart.artists.saturation[\"saturation_100\"].set_linewidth(8)\n",
"for rh_name in ('constant_relative_humidity_20', 'constant_relative_humidity_80'):\n",
"for rh_name in (\n",
" \"constant_relative_humidity_20\",\n",
" \"constant_relative_humidity_80\",\n",
"):\n",
" line = custom_chart.artists.constant_rh[rh_name]\n",
" line.set_linestyle(\":\")\n",
" line.set_linewidth(3)\n",
" line.set_color(\"darkblue\")\n",
"\n",
"print(\"\\n\\n** Customized style from preconfigured `minimal` style, with extra customizations:\")\n",
"print(\n",
" \"\\n\\n** Customized style from preconfigured `minimal` style, with extra customizations:\"\n",
")\n",
"svg_custom = custom_chart.make_svg()\n",
"HTML(svg_custom)"
]
Expand Down Expand Up @@ -14341,29 +14348,30 @@
" \"title\": \"My chart\",\n",
" \"x_label\": None,\n",
" \"y_label\": None,\n",
" \"partial_axis\": False\n",
" \"partial_axis\": False,\n",
" },\n",
" \"limits\": {\n",
" \"range_temp_c\": [10, 30],\n",
" \"range_humidity_g_kg\": [0, 25],\n",
" \"altitude_m\": 900,\n",
" \"step_temp\": .5\n",
" \"step_temp\": 0.5,\n",
" },\n",
" \"saturation\": {\"color\": [0, 0.3, 1.0], \"linewidth\": 2},\n",
" \"constant_rh\": {\n",
" \"color\": [0.0, 0.498, 1.0, 0.7],\n",
" \"linewidth\": 2.5,\n",
" \"linestyle\": \":\",\n",
" },\n",
" \"saturation\": {\"color\": [0, .3, 1.], \"linewidth\": 2},\n",
" \"constant_rh\": {\"color\": [0.0, 0.498, 1.0, .7], \"linewidth\": 2.5,\n",
" \"linestyle\": \":\"},\n",
" \"chart_params\": {\n",
" \"with_constant_rh\": True,\n",
" \"constant_rh_curves\": [25, 50, 75],\n",
" \"constant_rh_labels\": [25, 50, 75],\n",
" \n",
" \"range_vol_m3_kg\": [0.9, 1.],\n",
" \"range_vol_m3_kg\": [0.9, 1.0],\n",
" \"constant_v_labels\": [0.9, 0.94, 0.98],\n",
" \n",
" \"with_constant_h\": False,\n",
" \"with_constant_wet_temp\": False,\n",
" \"with_zones\": False\n",
" }\n",
" \"with_zones\": False,\n",
" },\n",
"}\n",
"\n",
"print(\"** Customized style from dict:\\n{}\\n\".format(custom_style))\n",
Expand Down Expand Up @@ -14411,29 +14419,36 @@
"source": [
"# Get a preconfigured chart\n",
"chart = PsychroChart.create(\"minimal\")\n",
"#chart.config.figure.figsize = (12, 8)\n",
"# chart.config.figure.figsize = (12, 8)\n",
"# Append zones:\n",
"zones_conf = {\n",
" \"zones\":[{\n",
" \"zones\": [\n",
" {\n",
" \"zone_type\": \"dbt-rh\",\n",
" \"style\": {\"edgecolor\": [1.0, 0.749, 0.0, 0.8],\n",
" \"facecolor\": [1.0, 0.749, 0.0, 0.2],\n",
" \"linewidth\": 2,\n",
" \"linestyle\": \"--\"},\n",
" \"style\": {\n",
" \"edgecolor\": [1.0, 0.749, 0.0, 0.8],\n",
" \"facecolor\": [1.0, 0.749, 0.0, 0.2],\n",
" \"linewidth\": 2,\n",
" \"linestyle\": \"--\",\n",
" },\n",
" \"points_x\": [23, 28],\n",
" \"points_y\": [40, 60],\n",
" \"label\": \"Summer\"\n",
" \"label\": \"Summer\",\n",
" },\n",
" {\n",
" \"zone_type\": \"dbt-rh\",\n",
" \"style\": {\"edgecolor\": [0.498, 0.624, 0.8],\n",
" \"facecolor\": [0.498, 0.624, 1.0, 0.2],\n",
" \"linewidth\": 2,\n",
" \"linestyle\": \"--\"},\n",
" \"style\": {\n",
" \"edgecolor\": [0.498, 0.624, 0.8],\n",
" \"facecolor\": [0.498, 0.624, 1.0, 0.2],\n",
" \"linewidth\": 2,\n",
" \"linestyle\": \"--\",\n",
" },\n",
" \"points_x\": [18, 23],\n",
" \"points_y\": [35, 55],\n",
" \"label\": \"Winter\"\n",
" }]}\n",
" \"label\": \"Winter\",\n",
" },\n",
" ]\n",
"}\n",
"chart.append_zones(zones_conf)\n",
"\n",
"# Plot the chart\n",
Expand All @@ -14442,44 +14457,85 @@
"# Add Vertical lines\n",
"t_min, t_opt, t_max = 16, 23, 30\n",
"chart.plot_vertical_dry_bulb_temp_line(\n",
" t_min, {\"color\": [0.0, 0.125, 0.376], \"lw\": 2, \"ls\": ':'},\n",
" ' TOO COLD ({}°C)'.format(t_min), ha='left', loc=0., fontsize=14)\n",
" t_min,\n",
" {\"color\": [0.0, 0.125, 0.376], \"lw\": 2, \"ls\": \":\"},\n",
" \" TOO COLD ({}°C)\".format(t_min),\n",
" ha=\"left\",\n",
" loc=0.0,\n",
" fontsize=14,\n",
")\n",
"chart.plot_vertical_dry_bulb_temp_line(\n",
" t_opt, {\"color\": [0.475, 0.612, 0.075], \"lw\": 2, \"ls\": ':'})\n",
" t_opt, {\"color\": [0.475, 0.612, 0.075], \"lw\": 2, \"ls\": \":\"}\n",
")\n",
"chart.plot_vertical_dry_bulb_temp_line(\n",
" t_max, {\"color\": [1.0, 0.0, 0.247], \"lw\": 2, \"ls\": ':'},\n",
" 'TOO HOT ({}°C) '.format(t_max), ha='right', loc=1,\n",
" reverse=True, fontsize=14)\n",
" t_max,\n",
" {\"color\": [1.0, 0.0, 0.247], \"lw\": 2, \"ls\": \":\"},\n",
" \"TOO HOT ({}°C) \".format(t_max),\n",
" ha=\"right\",\n",
" loc=1,\n",
" reverse=True,\n",
" fontsize=14,\n",
")\n",
"\n",
"# Add labelled points and conexions between points\n",
"points = {'exterior': {'label': 'Exterior',\n",
" 'style': {'color': [0.855, 0.004, 0.278, 0.8],\n",
" 'marker': 'X', 'markersize': 15},\n",
" 'xy': (31.06, 32.9)},\n",
" 'exterior_estimated': {\n",
" 'label': 'Estimated (Weather service)',\n",
" 'style': {'color': [0.573, 0.106, 0.318, 0.5],\n",
" 'marker': 'x', 'markersize': 10},\n",
" 'xy': (36.7, 25.0)},\n",
" 'interior': {'label': 'Interior',\n",
" 'style': {'color': [0.592, 0.745, 0.051, 0.9],\n",
" 'marker': 'o', 'markersize': 30},\n",
" 'xy': (29.42, 52.34)}}\n",
"connectors = [{'start': 'exterior',\n",
" 'end': 'exterior_estimated',\n",
" 'label': 'Process 1',\n",
" 'style': {'color': [0.573, 0.106, 0.318, 0.7],\n",
" \"linewidth\": 2, \"linestyle\": \"-.\"}},\n",
" {'start': 'exterior',\n",
" 'end': 'interior',\n",
" 'label': 'Process 2',\n",
" 'style': {'color': [0.855, 0.145, 0.114, 0.8],\n",
" \"linewidth\": 2, \"linestyle\": \":\"},\n",
" 'outline_marker_width': 30}]\n",
"points = {\n",
" \"exterior\": {\n",
" \"label\": \"Exterior\",\n",
" \"style\": {\n",
" \"color\": [0.855, 0.004, 0.278, 0.8],\n",
" \"marker\": \"X\",\n",
" \"markersize\": 15,\n",
" },\n",
" \"xy\": (31.06, 32.9),\n",
" },\n",
" \"exterior_estimated\": {\n",
" \"label\": \"Estimated (Weather service)\",\n",
" \"style\": {\n",
" \"color\": [0.573, 0.106, 0.318, 0.5],\n",
" \"marker\": \"x\",\n",
" \"markersize\": 10,\n",
" },\n",
" \"xy\": (36.7, 25.0),\n",
" },\n",
" \"interior\": {\n",
" \"label\": \"Interior\",\n",
" \"style\": {\n",
" \"color\": [0.592, 0.745, 0.051, 0.9],\n",
" \"marker\": \"o\",\n",
" \"markersize\": 30,\n",
" },\n",
" \"xy\": (29.42, 52.34),\n",
" },\n",
"}\n",
"connectors = [\n",
" {\n",
" \"start\": \"exterior\",\n",
" \"end\": \"exterior_estimated\",\n",
" \"label\": \"Process 1\",\n",
" \"style\": {\n",
" \"color\": [0.573, 0.106, 0.318, 0.7],\n",
" \"linewidth\": 2,\n",
" \"linestyle\": \"-.\",\n",
" },\n",
" },\n",
" {\n",
" \"start\": \"exterior\",\n",
" \"end\": \"interior\",\n",
" \"label\": \"Process 2\",\n",
" \"style\": {\n",
" \"color\": [0.855, 0.145, 0.114, 0.8],\n",
" \"linewidth\": 2,\n",
" \"linestyle\": \":\",\n",
" },\n",
" \"outline_marker_width\": 30,\n",
" },\n",
"]\n",
"chart.plot_points_dbt_rh(points, connectors)\n",
"\n",
"# Add a legend\n",
"chart.plot_legend(markerscale=.7, frameon=False, fontsize=10, labelspacing=1.2)\n",
"chart.plot_legend(\n",
" markerscale=0.7, frameon=False, fontsize=10, labelspacing=1.2\n",
")\n",
"\n",
"# show as matplotlib figure\n",
"%matplotlib inline\n",
Expand All @@ -14506,13 +14562,20 @@
"source": [
"# use like any other matplotlib object to overlay info in chart coordinates\n",
"ax.text(\n",
" 32, 22, \" \", ha=\"center\", va=\"center\", size=15, \n",
" bbox=dict(boxstyle=\"circle,pad=0.3\", fc=\"orange\", ec=\"darkred\", lw=2)\n",
" 32,\n",
" 22,\n",
" \" \",\n",
" ha=\"center\",\n",
" va=\"center\",\n",
" size=15,\n",
" bbox=dict(boxstyle=\"circle,pad=0.3\", fc=\"orange\", ec=\"darkred\", lw=2),\n",
")\n",
"ax.annotate(\n",
" \"That's hell\", xy=(32, 22), xytext=(35, 18),\n",
" \"That's hell\",\n",
" xy=(32, 22),\n",
" xytext=(35, 18),\n",
" fontsize=20,\n",
" arrowprops=dict(color='darkorange', headwidth=10, width=2, shrink=0.15)\n",
" arrowprops=dict(color=\"darkorange\", headwidth=10, width=2, shrink=0.15),\n",
")\n",
"\n",
"ax.get_figure()"
Expand Down

0 comments on commit 837eda3

Please sign in to comment.