Package: plot4gmns
Plot4GMNS: An open-source academic research tool for visualizing multimodal networks for transportation system modeling and optimizationAuthors:Dr. Junhua Chen, Zanyang Cui, Xiangyong LuoEmail:cjh@bjtu.edu.cn,zanyangcui@outlook.com,luoxiangyong01@gmail.comTable of ContentsIntroductionRequirementsInstallFeaturesUsageQuickstartAdvanceContributingIntroductionTo enable rapid transportation modeling and optimization, as traffic management researchers, we provide this free open-source tool for visualizing multimodal networks. Based on GMNS data format byZepha foundation, plot4gmns is designed for reading and plotting multimodal data sets including transportation network files, demand and agent trace files.Requirementspandasshapelymatplotlibnumpyseabornscipychardetkeplergl==0.3.2Installpipinstallplot4gmnsNoteFor Windows users, thepipmethod might fail to install some dependencies. If errors occur when you try to install any of those dependencies, try instead to pip install their .whl files, which can be downloaded from the Unoffical Windows Binaries forPython Extension Packages.Featuresweb-based network visualizationshow networks in different modesshow network with given node typesshow network by given link typesshow network by given link attributes rangeshow network by link attributes distributionshow network with given POI typesshow network by poi attributes distributionshow network demand matrix heatmapshow network demand ODShow only network elements of interestShow different networks on one diagramSet the drawing styleUsageBefore starting, you must have prepared network files, including node.csv, link.csv, poi.csv, demand.csv, and zone.csv. Theosm2gmnspackage will help you quickly obtain node, link, and poi data, and thegrid2demandpackage will help you obtain network demand and zone information.QuickstartStep 1: generate multimodal networkimportplot4gmnsasp4gmnet=p4g.generate_multi_network_from_csv(r'./datasets')After executing the above command, you will get an Html file, as shown below. More visual operations are supported on the web site..Step 2: show networks in different modes# draw 'all' modes network and save to png filecf=p4g.show_network_by_modes(mnet=mnet)# show the figure on the current windowcf.show()# show 'bike' mode networkcf=p4g.show_network_by_modes(mnet=mnet,modes=['bike'])cf.show()# show the figure on the current windowStep 3: show network with given node typescf=p4g.show_network_by_node_types(mnet=mnet,osm_highway=['traffic_signals','crossing'])cf.show()Step 4: show network by given link types# show network by given link typescf=p4g.show_network_by_link_types(mnet=mnet,link_types=['secondary','footway'])cf.show()Step 5: show network by given link attributes range# show network by given link length rangecf=p4g.show_network_by_link_length(mnet=mnet,min_length=10,max_length=50)cf.show()# show network by given link lane rangecf=p4g.show_network_by_link_lanes(mnet=mnet,min_lanes=1,max_lanes=3)cf.show()# show network by given link free speed rangecf=p4g.show_network_by_link_free_speed(mnet=mnet,min_free_speed=10,max_free_speed=40)cf.show()Step 6: show network by link attributes distribution# show network by link lane distributioncf=p4g.show_network_by_link_lane_distribution(mnet=mnet)cf.show()# show network by link capacity distributioncf=p4g.show_network_by_link_capacity_distribution(mnet=mnet)cf.show()# show network by link free speed distributioncf=p4g.show_network_by_link_free_speed_distribution(mnet=mnet)cf.show()Step 7: show network with given POI typescf=p4g.show_network_by_poi_types(mnet=mnet,poi_type=['public','industrial'])cf.show()Step 8: show network by poi attributes distribution# show network by poi attraction distributioncf=p4g.show_network_by_poi_attraction_distribution(mnet=mnet)cf.show()# show network by poi production distributioncf=p4g.show_network_by_poi_production_distribution(mnet=mnet)cf.show()Step 9: show network demand matrix heatmapcf=p4g.show_network_demand_matrix_heatmap(mnet)cf.show()Step 10: show network demand ODcf=p4g.show_network_by_demand_OD(mnet=mnet,load_network=True)cf.show()Advance UsageStep 1: Show only network elements of interestThe tool displays all elements by default, such as nodes, links, and POIs. If you want to display only the elements of interest, you can refer to the following example to modify the state of other elements before invoking the drawing command.# not show nodesmnet.node_loaded=Falsecf=p4g.show_network_by_link_lane_distribution(mnet=mnet)cf.show()Step 2: Show different networks on one diagramBy default, this tool will clear the original contents before drawing. If you want to draw different content on a graph, you can refer to the following examplemnet.node_loaded=Falsemnet.POI_loaded=Falsecf=p4g.show_network_by_link_lane_distribution(mnet=mnet)mnet.link_loaded=Falsemnet.POI_loaded=Truecf=p4g.show_network_by_poi_attraction_distribution(mnet,fig_obj=cf)cf.show()Step 3: Set the drawing styleUsers can refer to the following examples to adjust the color, size and other attributes of the image before drawing.parameterValueDescriptionmnet.style.figure_sizetuple,(width,height)Image sizemnet.style.dpiintthe resolution in dots per inch.mnet.style.node_style.sizeintnode marker sizemnet.style.node_style.colorsdict,{node_type:color}node color in different typesmnet.style.node_style.markersdict,{node_type:marker}node marker in different typesmnet.style.link_style.linecolorstrlink colormnet.style.link_style.linewidthfloatlink widthmnet.style.poi_style.facecolorstrPOI facecolormnet.style.poi_style.edgecolorstrPOI edgecolormnet.style.demand_style.linecolorstrdemand flow line colormnet.style.demand_style.linelinewidthfloatdemand flow line widthmnet.style.zone_style.linewidthfloatzone grid line widthmnet.style.zone_style.edgecolorsstrzone grid edgecolorsmnet.style.zone_style.fontsizeintzone label font sizemnet.style.zone_style.fontcolorstrzone label font colormnet.style.node_style.size=3mnet.style.link_style.linecolor='green'mnet.style.poi_style.facecolor='gray'cf=p4g.show_network_by_modes(mnet=mnet)cf.show()ContributingFeel free to dive in!Open an issue.Contributors@PraiseC@xyluo25Changelog2023-01-25 -- v0.1.1:Support web-based network visualization(Kepler.gl)TODO LISTAdd OD 3D visualization