|
245 | 245 | " nts[name] = nt" |
246 | 246 | ] |
247 | 247 | }, |
| 248 | + { |
| 249 | + "cell_type": "code", |
| 250 | + "execution_count": null, |
| 251 | + "metadata": {}, |
| 252 | + "outputs": [], |
| 253 | + "source": [ |
| 254 | + "len(nts)" |
| 255 | + ] |
| 256 | + }, |
248 | 257 | { |
249 | 258 | "cell_type": "markdown", |
250 | 259 | "metadata": {}, |
|
260 | 269 | "source": [ |
261 | 270 | "import matplotlib.pyplot as plt\n", |
262 | 271 | "\n", |
| 272 | + "from pedpy import plot_nt\n", |
| 273 | + "\n", |
| 274 | + "prop_cycle = plt.rcParams[\"axes.prop_cycle\"]\n", |
| 275 | + "colors = prop_cycle.by_key()[\"color\"]\n", |
| 276 | + "\n", |
263 | 277 | "fig = plt.figure(figsize=(7, 7))\n", |
264 | 278 | "ax1 = fig.add_subplot(111)\n", |
| 279 | + "ii = 0\n", |
265 | 280 | "\n", |
266 | 281 | "for name, nt in nts.items():\n", |
267 | | - " ax1.plot(nt.time, nt.cumulative_pedestrians, label=name)\n", |
| 282 | + " plot_nt(axes=ax1, nt=nt, label=name, color=colors[ii])\n", |
| 283 | + " ii += 1\n", |
268 | 284 | "\n", |
269 | 285 | "ax1.legend()\n", |
270 | 286 | "ax1.set_xlabel(\"time / s\")\n", |
|
498 | 514 | "metadata": {}, |
499 | 515 | "outputs": [], |
500 | 516 | "source": [ |
| 517 | + "from pedpy import PEDPY_BLUE, PEDPY_RED, plot_density, plot_speed\n", |
| 518 | + "\n", |
501 | 519 | "fig, ax = plt.subplots(nrows=len(trajectories.values()), ncols=2, figsize=(20, 60))\n", |
502 | 520 | "row = 0\n", |
503 | 521 | "\n", |
504 | | - "ax[row, 1].set_title(\"Velocity\", size=\"xx-large\")\n", |
505 | | - "ax[row, 0].set_title(\"Density\", size=\"xx-large\")\n", |
506 | | - "\n", |
507 | 522 | "for name, trajectory in trajectories.items():\n", |
508 | 523 | " ax[row, 0].annotate(\n", |
509 | 524 | " name,\n", |
|
517 | 532 | " rotation=90,\n", |
518 | 533 | " )\n", |
519 | 534 | "\n", |
520 | | - " ax[row, 0].plot(\n", |
521 | | - " classic_densities[name][FRAME_COL],\n", |
522 | | - " classic_densities[name][DENSITY_COL],\n", |
523 | | - " alpha=1,\n", |
524 | | - " )\n", |
| 535 | + " plot_density(axes=ax[row, 0], density=classic_densities[name], color=PEDPY_BLUE)\n", |
525 | 536 | " ax[row, 0].set_xlim(left=0)\n", |
526 | 537 | " ax[row, 0].set_ylim(bottom=0, top=4)\n", |
527 | | - " ax[row, 0].set_xlabel(\"frame\")\n", |
528 | | - " ax[row, 0].set_ylabel(\"rho / 1/m^2\")\n", |
529 | 538 | " ax[row, 0].grid()\n", |
530 | 539 | "\n", |
531 | | - " ax[row, 1].plot(mean_area_speeds[name].frame, mean_area_speeds[name].speed, alpha=1)\n", |
| 540 | + " plot_speed(axes=ax[row, 1], speed=mean_area_speeds[name], color=PEDPY_RED)\n", |
532 | 541 | " ax[row, 1].set_xlim(\n", |
533 | 542 | " left=0,\n", |
534 | 543 | " )\n", |
535 | 544 | " ax[row, 1].set_ylim(bottom=0, top=3)\n", |
536 | | - " ax[row, 1].set_xlabel(\"frame\")\n", |
537 | | - " ax[row, 1].set_ylabel(\"v / m/s\")\n", |
538 | 545 | " ax[row, 1].grid()\n", |
539 | 546 | "\n", |
540 | | - " row += 1" |
| 547 | + " row += 1\n", |
| 548 | + "ax[0, 1].set_title(\"Speed\", size=\"xx-large\")\n", |
| 549 | + "ax[0, 0].set_title(\"Density\", size=\"xx-large\")\n", |
| 550 | + "\n", |
| 551 | + "plt.show()" |
541 | 552 | ] |
542 | 553 | }, |
543 | 554 | { |
|
717 | 728 | "metadata": {}, |
718 | 729 | "outputs": [], |
719 | 730 | "source": [ |
| 731 | + "from pedpy import PEDPY_BLUE, PEDPY_ORANGE, plot_density, plot_speed\n", |
| 732 | + "\n", |
720 | 733 | "fig, ax = plt.subplots(nrows=len(trajectories.values()), ncols=2, figsize=(20, 60))\n", |
721 | 734 | "row = 0\n", |
722 | 735 | "\n", |
723 | | - "ax[row, 1].set_title(\"Speed\", size=\"xx-large\")\n", |
724 | | - "ax[row, 0].set_title(\"Density\", size=\"xx-large\")\n", |
725 | | - "\n", |
726 | 736 | "for name, trajectory in trajectories.items():\n", |
727 | 737 | " ax[row, 0].annotate(\n", |
728 | 738 | " name,\n", |
|
736 | 746 | " rotation=90,\n", |
737 | 747 | " )\n", |
738 | 748 | "\n", |
739 | | - " ax[row, 0].plot(\n", |
740 | | - " voronoi_densities[name][FRAME_COL],\n", |
741 | | - " voronoi_densities[name][DENSITY_COL],\n", |
742 | | - " alpha=1,\n", |
743 | | - " label=\"without cut-off\",\n", |
744 | | - " )\n", |
745 | | - " ax[row, 0].plot(\n", |
746 | | - " voronoi_densities_cutoff[name][FRAME_COL],\n", |
747 | | - " voronoi_densities_cutoff[name][DENSITY_COL],\n", |
748 | | - " alpha=1,\n", |
749 | | - " label=\"with cut-off\",\n", |
750 | | - " )\n", |
| 749 | + " plot_density(axes=ax[row, 0], density=voronoi_densities[name], label=\"without cut-off\", color=PEDPY_BLUE)\n", |
| 750 | + " plot_density(axes=ax[row, 0], density=voronoi_densities_cutoff[name], label=\"with cut-off\", color=PEDPY_ORANGE)\n", |
751 | 751 | " ax[row, 0].set_xlim(left=0)\n", |
752 | 752 | " ax[row, 0].set_ylim(bottom=0, top=4)\n", |
753 | | - " ax[row, 0].set_xlabel(\"frame\")\n", |
754 | | - " ax[row, 0].set_ylabel(\"rho / 1/m^2\")\n", |
755 | 753 | " ax[row, 0].grid()\n", |
756 | 754 | " ax[row, 0].legend()\n", |
757 | 755 | "\n", |
758 | | - " ax[row, 1].plot(\n", |
759 | | - " voronoi_speeds[name][FRAME_COL],\n", |
760 | | - " voronoi_speeds[name][SPEED_COL],\n", |
761 | | - " alpha=1,\n", |
762 | | - " label=\"without cut-off\",\n", |
763 | | - " )\n", |
764 | | - " ax[row, 1].plot(\n", |
765 | | - " voronoi_speeds_cutoff[name][FRAME_COL],\n", |
766 | | - " voronoi_speeds_cutoff[name][SPEED_COL],\n", |
767 | | - " alpha=1,\n", |
768 | | - " label=\"with cut-off\",\n", |
769 | | - " )\n", |
| 756 | + " plot_speed(axes=ax[row, 1], speed=voronoi_speeds[name], label=\"without cut-off\", color=PEDPY_BLUE)\n", |
| 757 | + " plot_speed(axes=ax[row, 1], speed=voronoi_speeds_cutoff[name], label=\"with cut-off\", color=PEDPY_ORANGE)\n", |
770 | 758 | " ax[row, 1].set_xlim(\n", |
771 | 759 | " left=0,\n", |
772 | 760 | " )\n", |
773 | 761 | " ax[row, 1].set_ylim(bottom=0, top=3)\n", |
774 | | - " ax[row, 1].set_xlabel(\"frame\")\n", |
775 | | - " ax[row, 1].set_ylabel(\"v / m/s\")\n", |
776 | 762 | " ax[row, 1].grid()\n", |
777 | 763 | " ax[row, 1].legend()\n", |
778 | 764 | " row += 1\n", |
| 765 | + "\n", |
| 766 | + "ax[0, 1].set_title(\"Speed\", size=\"xx-large\")\n", |
| 767 | + "ax[0, 0].set_title(\"Density\", size=\"xx-large\")\n", |
779 | 768 | "plt.show()" |
780 | 769 | ] |
781 | 770 | }, |
|
1003 | 992 | "# Start plotting\n", |
1004 | 993 | "fig = plt.figure(layout=\"constrained\")\n", |
1005 | 994 | "ax1 = fig.add_subplot(131, aspect=\"equal\")\n", |
1006 | | - "ax1.set_title(\"Color by density\")\n", |
1007 | 995 | "plot_voronoi_cells(\n", |
1008 | 996 | " voronoi_data=combined_data,\n", |
1009 | 997 | " walkable_area=walkable_area,\n", |
|
1014 | 1002 | " ped_size=5,\n", |
1015 | 1003 | " voronoi_outside_ma_alpha=0.4,\n", |
1016 | 1004 | " axes=ax1,\n", |
| 1005 | + " title=\"Color by density\",\n", |
1017 | 1006 | ")\n", |
1018 | 1007 | "\n", |
1019 | 1008 | "ax2 = fig.add_subplot(132, aspect=\"equal\")\n", |
1020 | | - "ax2.set_title(\"Color by speed\")\n", |
1021 | 1009 | "plot_voronoi_cells(\n", |
1022 | 1010 | " voronoi_data=combined_data,\n", |
1023 | 1011 | " walkable_area=walkable_area,\n", |
|
1028 | 1016 | " ped_size=5,\n", |
1029 | 1017 | " voronoi_outside_ma_alpha=0.4,\n", |
1030 | 1018 | " axes=ax2,\n", |
| 1019 | + " title=\"Color by speed\",\n", |
1031 | 1020 | ")\n", |
1032 | 1021 | "\n", |
1033 | 1022 | "ax3 = fig.add_subplot(133, aspect=\"equal\")\n", |
1034 | | - "ax3.set_title(\"Color by id\")\n", |
1035 | 1023 | "plot_voronoi_cells(\n", |
1036 | 1024 | " voronoi_data=combined_data,\n", |
1037 | 1025 | " walkable_area=walkable_area,\n", |
|
1042 | 1030 | " ped_size=5,\n", |
1043 | 1031 | " voronoi_outside_ma_alpha=0.4,\n", |
1044 | 1032 | " axes=ax3,\n", |
| 1033 | + " show_colorbar=False,\n", |
| 1034 | + " title=\"Color by id\",\n", |
1045 | 1035 | ")\n", |
1046 | 1036 | "plt.show()" |
1047 | 1037 | ] |
|
0 commit comments