Skip to main content

A visualization tool for line plan

Project description

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

line_plan_visualization-0.0.6.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

line_plan_visualization-0.0.6-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file line_plan_visualization-0.0.6.tar.gz.

File metadata

  • Download URL: line_plan_visualization-0.0.6.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for line_plan_visualization-0.0.6.tar.gz
Algorithm Hash digest
SHA256 e0c3a3d75371c7250f00f5945bc306c59b432e19a0e59b54f6065e78e3dc821c
MD5 01d6a03b94373f08c2c20e7cd1df41ac
BLAKE2b-256 86e36a44ebce280af11e1246417cb8a8cbd47f4f886c0189e5449ea60552aabe

See more details on using hashes here.

File details

Details for the file line_plan_visualization-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for line_plan_visualization-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bcaf26e76772b8e282367c6d59525cf4b36379e39c3cdb0a4e0e4937e9157cae
MD5 11c92a08e40937f07121bd2d98f06247
BLAKE2b-256 55ad8381f58d77f3d7b45bb0a53f40d8259e507d84b826fa3f46bd955be2c88e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page