Skip to main content

LinePlanVisualization

A visualization tool for line plan based on matplotlib.
According to our specified data structure, your line plan can be visualized easily, and also we provide a lot of parameters to adjust the appearance.

Install

pip install line_plan_visualization

Usage

This tool consists of three main classes: PhysicalRailway, Lines and LinePlan.

PhysicalRailway

This class represents the physical railway to visualize.
When creating an instance of PhysicalRailway, the fisrt parameter you need to pass in should be str type representing the name of the railway. The second parameter should be dict type which the keys are str type representing the names of stations and the values are str type representing stations' levels. The level should be one of "high", "medium" and "low". The order of the stations in the dictionary is the order of the visualization.

# an instance of class PhysicalRailway 
example_pr = PhysicalRailWay("Beijing-Shanghai High-Speed Raiway",  # railway name
                             {"BJN": "high",  # stations names and levels in order
                              "LF": "low",
                              "TJN": "high",
                              "CZX": "medium",
                              "DZD": "medium",
                              "JNX": "high",
                              "TA": "medium",
                              "QFD": "medium",
                              "TZD": "low",
                              "ZZ": "low",
                              "XZD": "high",
                              "SZD": "low",
                              "BBN": "medium",
                              "DY": "low",
                              "CZ": "low",
                              "NJN": "high",
                              "ZJN": "medium",
                              "DYB": "low",
                              "CZB": "medium",
                              "WXD": "medium",
                              "SZB": "medium",
                              "KSN": "medium",
                              "SHHQ": "high"})

Lines

This class represents the train lines operating on the physical railway.
When creating an instance of Lines, the only parameter you need to pass in should be dict type which the keys are int type representing the IDs of lines(Sequentiality is not enforced) and the values are list type only containing 0 and 1 for no stop and stop at the station corresponding to the physical railway.

# 50 lines are randomly generated and lineIDs do not have to start at 0 or are ordered
lines = {}
for idx in range(25):
    lines[idx] = [random.randint(0, 1) for _ in range(len(example_pr))]  # len(example_pr) returns the num of stations

# an instance of class Lines
example_lines = Lines(lines)

LinePlan

This class combines PyhsicalRailway and Lines. When creating an instance of LinePlan, the only two parameters you need to pass in are an instance of PhysicalRailway and an instance of Line.

# an instance of class LinePlan
example_lp = LinePlan(example_pr, example_lines)

Now the line plan can be visualized by calling the function draw.

example_lp.draw()

However, the default appearance parameters may not be appropriate for your line plan, you can also pass in some custom parameters. See documentation of function draw for details. Overall, they are similar to the syntax and usage of matplotlib.

example_lp.draw(figsize=(23, 25),
                lines_color='blue')

Make sure that the function show is called after the function save, otherwise your saved image will be blank(For some unknown reasons, the saved image is the real one, the displayed image are indicative only, if you reckon the displayed image is ugly, you may wish to take a look at the saved image).

example_lp.save("fig\\testimage.png")
example_lp.show()

Release files for line-plan-visualization 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for line-plan-visualization 0.0.6
File Size Uploaded
line_plan_visualization-0.0.6.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for line-plan-visualization 0.0.6
File Interpreter ABI Platform
line_plan_visualization-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 17.8 kB

Release files / line_plan_visualization-0.0.6.tar.gz

Download URL line_plan_visualization-0.0.6.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e0c3a3d75371c7250f00f5945bc306c59b432e19a0e59b54f6065e78e3dc821c
BLAKE2b-256 checksum
How to use checksums
86e36a44ebce280af11e1246417cb8a8cbd47f4f886c0189e5449ea60552aabe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / line_plan_visualization-0.0.6-py3-none-any.whl

Download URL line_plan_visualization-0.0.6-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcaf26e76772b8e282367c6d59525cf4b36379e39c3cdb0a4e0e4937e9157cae
BLAKE2b-256 checksum
How to use checksums
55ad8381f58d77f3d7b45bb0a53f40d8259e507d84b826fa3f46bd955be2c88e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page