78627862 ],
78637863 "source": [
78647864 "print(\"** Customized chart style (from `ashrae`), Zoom in [15, 35]:\")\n",
7865- "chart_ashrae_style = PsychroChart.create(' ashrae' )\n",
7865+ "chart_ashrae_style = PsychroChart.create(\" ashrae\" )\n",
78667866 "\n",
78677867 "# zoom in\n",
78687868 "chart_ashrae_style.config.figure.title = None\n",
78697869 "chart_ashrae_style.config.limits.range_temp_c = (15, 35)\n",
78707870 "chart_ashrae_style.config.limits.range_humidity_g_kg = (0, 25)\n",
7871- "chart_ashrae_style.config.saturation.color = ' darkorange' \n",
7871+ "chart_ashrae_style.config.saturation.color = \" darkorange\" \n",
78727872 "chart_ashrae_style.config.saturation.linewidth = 4\n",
78737873 "\n",
78747874 "svg_ashrae = chart_ashrae_style.make_svg()\n",
1198911989 ],
1199011990 "source": [
1199111991 "print(\"** Preconfigured chart style: `ashrae_ip`:\")\n",
11992- "chart_ashrae_ip = PsychroChart.create(' ashrae_ip' , use_unit_system_si=False)\n",
11992+ "chart_ashrae_ip = PsychroChart.create(\" ashrae_ip\" , use_unit_system_si=False)\n",
1199311993 "svg_ashrae_ip = chart_ashrae_ip.make_svg()\n",
1199411994 "HTML(svg_ashrae_ip)"
1199511995 ]
@@ -12672,21 +12672,28 @@
1267212672 "custom_chart.config.chart_params.with_constant_wet_temp = False\n",
1267312673 "custom_chart.config.chart_params.with_constant_h = False\n",
1267412674 "\n",
12675- "# plot to generate matplotlib objects, and continue customizing the chart 🌈 \n",
12675+ "# plot to generate matplotlib objects, and continue customizing the chart 🌈\n",
1267612676 "custom_chart.plot()\n",
1267712677 "# show names of objects in plot\n",
12678- "print(\"** Each object in plot has a readable name to access it for fine-grain customizations:\")\n",
12678+ "print(\n",
12679+ " \"** Each object in plot has a readable name to access it for fine-grain customizations:\"\n",
12680+ ")\n",
1267912681 "print(custom_chart.artists.render_tree())\n",
1268012682 "\n",
1268112683 "# apply customizations for single objects in plot\n",
1268212684 "custom_chart.artists.saturation[\"saturation_100\"].set_linewidth(8)\n",
12683- "for rh_name in ('constant_relative_humidity_20', 'constant_relative_humidity_80'):\n",
12685+ "for rh_name in (\n",
12686+ " \"constant_relative_humidity_20\",\n",
12687+ " \"constant_relative_humidity_80\",\n",
12688+ "):\n",
1268412689 " line = custom_chart.artists.constant_rh[rh_name]\n",
1268512690 " line.set_linestyle(\":\")\n",
1268612691 " line.set_linewidth(3)\n",
1268712692 " line.set_color(\"darkblue\")\n",
1268812693 "\n",
12689- "print(\"\\n\\n** Customized style from preconfigured `minimal` style, with extra customizations:\")\n",
12694+ "print(\n",
12695+ " \"\\n\\n** Customized style from preconfigured `minimal` style, with extra customizations:\"\n",
12696+ ")\n",
1269012697 "svg_custom = custom_chart.make_svg()\n",
1269112698 "HTML(svg_custom)"
1269212699 ]
@@ -14341,29 +14348,30 @@
1434114348 " \"title\": \"My chart\",\n",
1434214349 " \"x_label\": None,\n",
1434314350 " \"y_label\": None,\n",
14344- " \"partial_axis\": False\n",
14351+ " \"partial_axis\": False, \n",
1434514352 " },\n",
1434614353 " \"limits\": {\n",
1434714354 " \"range_temp_c\": [10, 30],\n",
1434814355 " \"range_humidity_g_kg\": [0, 25],\n",
1434914356 " \"altitude_m\": 900,\n",
14350- " \"step_temp\": .5\n",
14357+ " \"step_temp\": 0.5,\n",
14358+ " },\n",
14359+ " \"saturation\": {\"color\": [0, 0.3, 1.0], \"linewidth\": 2},\n",
14360+ " \"constant_rh\": {\n",
14361+ " \"color\": [0.0, 0.498, 1.0, 0.7],\n",
14362+ " \"linewidth\": 2.5,\n",
14363+ " \"linestyle\": \":\",\n",
1435114364 " },\n",
14352- " \"saturation\": {\"color\": [0, .3, 1.], \"linewidth\": 2},\n",
14353- " \"constant_rh\": {\"color\": [0.0, 0.498, 1.0, .7], \"linewidth\": 2.5,\n",
14354- " \"linestyle\": \":\"},\n",
1435514365 " \"chart_params\": {\n",
1435614366 " \"with_constant_rh\": True,\n",
1435714367 " \"constant_rh_curves\": [25, 50, 75],\n",
1435814368 " \"constant_rh_labels\": [25, 50, 75],\n",
14359- " \n",
14360- " \"range_vol_m3_kg\": [0.9, 1.],\n",
14369+ " \"range_vol_m3_kg\": [0.9, 1.0],\n",
1436114370 " \"constant_v_labels\": [0.9, 0.94, 0.98],\n",
14362- " \n",
1436314371 " \"with_constant_h\": False,\n",
1436414372 " \"with_constant_wet_temp\": False,\n",
14365- " \"with_zones\": False\n",
14366- " }\n",
14373+ " \"with_zones\": False, \n",
14374+ " }, \n",
1436714375 "}\n",
1436814376 "\n",
1436914377 "print(\"** Customized style from dict:\\n{}\\n\".format(custom_style))\n",
@@ -14411,29 +14419,36 @@
1441114419 "source": [
1441214420 "# Get a preconfigured chart\n",
1441314421 "chart = PsychroChart.create(\"minimal\")\n",
14414- "#chart.config.figure.figsize = (12, 8)\n",
14422+ "# chart.config.figure.figsize = (12, 8)\n",
1441514423 "# Append zones:\n",
1441614424 "zones_conf = {\n",
14417- " \"zones\":[{\n",
14425+ " \"zones\": [\n",
14426+ " {\n",
1441814427 " \"zone_type\": \"dbt-rh\",\n",
14419- " \"style\": {\"edgecolor\": [1.0, 0.749, 0.0, 0.8],\n",
14420- " \"facecolor\": [1.0, 0.749, 0.0, 0.2],\n",
14421- " \"linewidth\": 2,\n",
14422- " \"linestyle\": \"--\"},\n",
14428+ " \"style\": {\n",
14429+ " \"edgecolor\": [1.0, 0.749, 0.0, 0.8],\n",
14430+ " \"facecolor\": [1.0, 0.749, 0.0, 0.2],\n",
14431+ " \"linewidth\": 2,\n",
14432+ " \"linestyle\": \"--\",\n",
14433+ " },\n",
1442314434 " \"points_x\": [23, 28],\n",
1442414435 " \"points_y\": [40, 60],\n",
14425- " \"label\": \"Summer\"\n",
14436+ " \"label\": \"Summer\", \n",
1442614437 " },\n",
1442714438 " {\n",
1442814439 " \"zone_type\": \"dbt-rh\",\n",
14429- " \"style\": {\"edgecolor\": [0.498, 0.624, 0.8],\n",
14430- " \"facecolor\": [0.498, 0.624, 1.0, 0.2],\n",
14431- " \"linewidth\": 2,\n",
14432- " \"linestyle\": \"--\"},\n",
14440+ " \"style\": {\n",
14441+ " \"edgecolor\": [0.498, 0.624, 0.8],\n",
14442+ " \"facecolor\": [0.498, 0.624, 1.0, 0.2],\n",
14443+ " \"linewidth\": 2,\n",
14444+ " \"linestyle\": \"--\",\n",
14445+ " },\n",
1443314446 " \"points_x\": [18, 23],\n",
1443414447 " \"points_y\": [35, 55],\n",
14435- " \"label\": \"Winter\"\n",
14436- " }]}\n",
14448+ " \"label\": \"Winter\",\n",
14449+ " },\n",
14450+ " ]\n",
14451+ "}\n",
1443714452 "chart.append_zones(zones_conf)\n",
1443814453 "\n",
1443914454 "# Plot the chart\n",
@@ -14442,44 +14457,85 @@
1444214457 "# Add Vertical lines\n",
1444314458 "t_min, t_opt, t_max = 16, 23, 30\n",
1444414459 "chart.plot_vertical_dry_bulb_temp_line(\n",
14445- " t_min, {\"color\": [0.0, 0.125, 0.376], \"lw\": 2, \"ls\": ':'},\n",
14446- " ' TOO COLD ({}°C)'.format(t_min), ha='left', loc=0., fontsize=14)\n",
14460+ " t_min,\n",
14461+ " {\"color\": [0.0, 0.125, 0.376], \"lw\": 2, \"ls\": \":\"},\n",
14462+ " \" TOO COLD ({}°C)\".format(t_min),\n",
14463+ " ha=\"left\",\n",
14464+ " loc=0.0,\n",
14465+ " fontsize=14,\n",
14466+ ")\n",
1444714467 "chart.plot_vertical_dry_bulb_temp_line(\n",
14448- " t_opt, {\"color\": [0.475, 0.612, 0.075], \"lw\": 2, \"ls\": ':'})\n",
14468+ " t_opt, {\"color\": [0.475, 0.612, 0.075], \"lw\": 2, \"ls\": \":\"}\n",
14469+ ")\n",
1444914470 "chart.plot_vertical_dry_bulb_temp_line(\n",
14450- " t_max, {\"color\": [1.0, 0.0, 0.247], \"lw\": 2, \"ls\": ':'},\n",
14451- " 'TOO HOT ({}°C) '.format(t_max), ha='right', loc=1,\n",
14452- " reverse=True, fontsize=14)\n",
14471+ " t_max,\n",
14472+ " {\"color\": [1.0, 0.0, 0.247], \"lw\": 2, \"ls\": \":\"},\n",
14473+ " \"TOO HOT ({}°C) \".format(t_max),\n",
14474+ " ha=\"right\",\n",
14475+ " loc=1,\n",
14476+ " reverse=True,\n",
14477+ " fontsize=14,\n",
14478+ ")\n",
1445314479 "\n",
1445414480 "# Add labelled points and conexions between points\n",
14455- "points = {'exterior': {'label': 'Exterior',\n",
14456- " 'style': {'color': [0.855, 0.004, 0.278, 0.8],\n",
14457- " 'marker': 'X', 'markersize': 15},\n",
14458- " 'xy': (31.06, 32.9)},\n",
14459- " 'exterior_estimated': {\n",
14460- " 'label': 'Estimated (Weather service)',\n",
14461- " 'style': {'color': [0.573, 0.106, 0.318, 0.5],\n",
14462- " 'marker': 'x', 'markersize': 10},\n",
14463- " 'xy': (36.7, 25.0)},\n",
14464- " 'interior': {'label': 'Interior',\n",
14465- " 'style': {'color': [0.592, 0.745, 0.051, 0.9],\n",
14466- " 'marker': 'o', 'markersize': 30},\n",
14467- " 'xy': (29.42, 52.34)}}\n",
14468- "connectors = [{'start': 'exterior',\n",
14469- " 'end': 'exterior_estimated',\n",
14470- " 'label': 'Process 1',\n",
14471- " 'style': {'color': [0.573, 0.106, 0.318, 0.7],\n",
14472- " \"linewidth\": 2, \"linestyle\": \"-.\"}},\n",
14473- " {'start': 'exterior',\n",
14474- " 'end': 'interior',\n",
14475- " 'label': 'Process 2',\n",
14476- " 'style': {'color': [0.855, 0.145, 0.114, 0.8],\n",
14477- " \"linewidth\": 2, \"linestyle\": \":\"},\n",
14478- " 'outline_marker_width': 30}]\n",
14481+ "points = {\n",
14482+ " \"exterior\": {\n",
14483+ " \"label\": \"Exterior\",\n",
14484+ " \"style\": {\n",
14485+ " \"color\": [0.855, 0.004, 0.278, 0.8],\n",
14486+ " \"marker\": \"X\",\n",
14487+ " \"markersize\": 15,\n",
14488+ " },\n",
14489+ " \"xy\": (31.06, 32.9),\n",
14490+ " },\n",
14491+ " \"exterior_estimated\": {\n",
14492+ " \"label\": \"Estimated (Weather service)\",\n",
14493+ " \"style\": {\n",
14494+ " \"color\": [0.573, 0.106, 0.318, 0.5],\n",
14495+ " \"marker\": \"x\",\n",
14496+ " \"markersize\": 10,\n",
14497+ " },\n",
14498+ " \"xy\": (36.7, 25.0),\n",
14499+ " },\n",
14500+ " \"interior\": {\n",
14501+ " \"label\": \"Interior\",\n",
14502+ " \"style\": {\n",
14503+ " \"color\": [0.592, 0.745, 0.051, 0.9],\n",
14504+ " \"marker\": \"o\",\n",
14505+ " \"markersize\": 30,\n",
14506+ " },\n",
14507+ " \"xy\": (29.42, 52.34),\n",
14508+ " },\n",
14509+ "}\n",
14510+ "connectors = [\n",
14511+ " {\n",
14512+ " \"start\": \"exterior\",\n",
14513+ " \"end\": \"exterior_estimated\",\n",
14514+ " \"label\": \"Process 1\",\n",
14515+ " \"style\": {\n",
14516+ " \"color\": [0.573, 0.106, 0.318, 0.7],\n",
14517+ " \"linewidth\": 2,\n",
14518+ " \"linestyle\": \"-.\",\n",
14519+ " },\n",
14520+ " },\n",
14521+ " {\n",
14522+ " \"start\": \"exterior\",\n",
14523+ " \"end\": \"interior\",\n",
14524+ " \"label\": \"Process 2\",\n",
14525+ " \"style\": {\n",
14526+ " \"color\": [0.855, 0.145, 0.114, 0.8],\n",
14527+ " \"linewidth\": 2,\n",
14528+ " \"linestyle\": \":\",\n",
14529+ " },\n",
14530+ " \"outline_marker_width\": 30,\n",
14531+ " },\n",
14532+ "]\n",
1447914533 "chart.plot_points_dbt_rh(points, connectors)\n",
1448014534 "\n",
1448114535 "# Add a legend\n",
14482- "chart.plot_legend(markerscale=.7, frameon=False, fontsize=10, labelspacing=1.2)\n",
14536+ "chart.plot_legend(\n",
14537+ " markerscale=0.7, frameon=False, fontsize=10, labelspacing=1.2\n",
14538+ ")\n",
1448314539 "\n",
1448414540 "# show as matplotlib figure\n",
1448514541 "%matplotlib inline\n",
@@ -14506,13 +14562,20 @@
1450614562 "source": [
1450714563 "# use like any other matplotlib object to overlay info in chart coordinates\n",
1450814564 "ax.text(\n",
14509- " 32, 22, \" \", ha=\"center\", va=\"center\", size=15, \n",
14510- " bbox=dict(boxstyle=\"circle,pad=0.3\", fc=\"orange\", ec=\"darkred\", lw=2)\n",
14565+ " 32,\n",
14566+ " 22,\n",
14567+ " \" \",\n",
14568+ " ha=\"center\",\n",
14569+ " va=\"center\",\n",
14570+ " size=15,\n",
14571+ " bbox=dict(boxstyle=\"circle,pad=0.3\", fc=\"orange\", ec=\"darkred\", lw=2),\n",
1451114572 ")\n",
1451214573 "ax.annotate(\n",
14513- " \"That's hell\", xy=(32, 22), xytext=(35, 18),\n",
14574+ " \"That's hell\",\n",
14575+ " xy=(32, 22),\n",
14576+ " xytext=(35, 18),\n",
1451414577 " fontsize=20,\n",
14515- " arrowprops=dict(color=' darkorange' , headwidth=10, width=2, shrink=0.15)\n",
14578+ " arrowprops=dict(color=\" darkorange\" , headwidth=10, width=2, shrink=0.15), \n",
1451614579 ")\n",
1451714580 "\n",
1451814581 "ax.get_figure()"
0 commit comments