7862
7862
],
7863
7863
"source": [
7864
7864
"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",
7866
7866
"\n",
7867
7867
"# zoom in\n",
7868
7868
"chart_ashrae_style.config.figure.title = None\n",
7869
7869
"chart_ashrae_style.config.limits.range_temp_c = (15, 35)\n",
7870
7870
"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",
7872
7872
"chart_ashrae_style.config.saturation.linewidth = 4\n",
7873
7873
"\n",
7874
7874
"svg_ashrae = chart_ashrae_style.make_svg()\n",
11989
11989
],
11990
11990
"source": [
11991
11991
"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",
11993
11993
"svg_ashrae_ip = chart_ashrae_ip.make_svg()\n",
11994
11994
"HTML(svg_ashrae_ip)"
11995
11995
]
@@ -12672,21 +12672,28 @@
12672
12672
"custom_chart.config.chart_params.with_constant_wet_temp = False\n",
12673
12673
"custom_chart.config.chart_params.with_constant_h = False\n",
12674
12674
"\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",
12676
12676
"custom_chart.plot()\n",
12677
12677
"# 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",
12679
12681
"print(custom_chart.artists.render_tree())\n",
12680
12682
"\n",
12681
12683
"# apply customizations for single objects in plot\n",
12682
12684
"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",
12684
12689
" line = custom_chart.artists.constant_rh[rh_name]\n",
12685
12690
" line.set_linestyle(\":\")\n",
12686
12691
" line.set_linewidth(3)\n",
12687
12692
" line.set_color(\"darkblue\")\n",
12688
12693
"\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",
12690
12697
"svg_custom = custom_chart.make_svg()\n",
12691
12698
"HTML(svg_custom)"
12692
12699
]
@@ -14341,29 +14348,30 @@
14341
14348
" \"title\": \"My chart\",\n",
14342
14349
" \"x_label\": None,\n",
14343
14350
" \"y_label\": None,\n",
14344
- " \"partial_axis\": False\n",
14351
+ " \"partial_axis\": False, \n",
14345
14352
" },\n",
14346
14353
" \"limits\": {\n",
14347
14354
" \"range_temp_c\": [10, 30],\n",
14348
14355
" \"range_humidity_g_kg\": [0, 25],\n",
14349
14356
" \"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",
14351
14364
" },\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",
14355
14365
" \"chart_params\": {\n",
14356
14366
" \"with_constant_rh\": True,\n",
14357
14367
" \"constant_rh_curves\": [25, 50, 75],\n",
14358
14368
" \"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",
14361
14370
" \"constant_v_labels\": [0.9, 0.94, 0.98],\n",
14362
- " \n",
14363
14371
" \"with_constant_h\": False,\n",
14364
14372
" \"with_constant_wet_temp\": False,\n",
14365
- " \"with_zones\": False\n",
14366
- " }\n",
14373
+ " \"with_zones\": False, \n",
14374
+ " }, \n",
14367
14375
"}\n",
14368
14376
"\n",
14369
14377
"print(\"** Customized style from dict:\\n{}\\n\".format(custom_style))\n",
@@ -14411,29 +14419,36 @@
14411
14419
"source": [
14412
14420
"# Get a preconfigured chart\n",
14413
14421
"chart = PsychroChart.create(\"minimal\")\n",
14414
- "#chart.config.figure.figsize = (12, 8)\n",
14422
+ "# chart.config.figure.figsize = (12, 8)\n",
14415
14423
"# Append zones:\n",
14416
14424
"zones_conf = {\n",
14417
- " \"zones\":[{\n",
14425
+ " \"zones\": [\n",
14426
+ " {\n",
14418
14427
" \"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",
14423
14434
" \"points_x\": [23, 28],\n",
14424
14435
" \"points_y\": [40, 60],\n",
14425
- " \"label\": \"Summer\"\n",
14436
+ " \"label\": \"Summer\", \n",
14426
14437
" },\n",
14427
14438
" {\n",
14428
14439
" \"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",
14433
14446
" \"points_x\": [18, 23],\n",
14434
14447
" \"points_y\": [35, 55],\n",
14435
- " \"label\": \"Winter\"\n",
14436
- " }]}\n",
14448
+ " \"label\": \"Winter\",\n",
14449
+ " },\n",
14450
+ " ]\n",
14451
+ "}\n",
14437
14452
"chart.append_zones(zones_conf)\n",
14438
14453
"\n",
14439
14454
"# Plot the chart\n",
@@ -14442,44 +14457,85 @@
14442
14457
"# Add Vertical lines\n",
14443
14458
"t_min, t_opt, t_max = 16, 23, 30\n",
14444
14459
"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",
14447
14467
"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",
14449
14470
"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",
14453
14479
"\n",
14454
14480
"# 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",
14479
14533
"chart.plot_points_dbt_rh(points, connectors)\n",
14480
14534
"\n",
14481
14535
"# 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",
14483
14539
"\n",
14484
14540
"# show as matplotlib figure\n",
14485
14541
"%matplotlib inline\n",
@@ -14506,13 +14562,20 @@
14506
14562
"source": [
14507
14563
"# use like any other matplotlib object to overlay info in chart coordinates\n",
14508
14564
"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",
14511
14572
")\n",
14512
14573
"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",
14514
14577
" 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",
14516
14579
")\n",
14517
14580
"\n",
14518
14581
"ax.get_figure()"
0 commit comments