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
Built Distribution
Hashes for line_plan_visualization-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8aa1b4df817c08299fa1ba1fdc2436652f8b3ebfec6c7700b6df6e0b26337efd |
|
MD5 | 34a9b17a8dc6b8dff2f9092bf24da24d |
|
BLAKE2b-256 | 8bac6bf4b3d23696d182948c390ddacb908304b085b6588f7cc71d2a24ba608e |
Hashes for line_plan_visualization-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cea13007bc22067ab228763b8dcb9e8a30ab8ad73522408bf67347e01cce7af5 |
|
MD5 | 5e10d460ca5a93cee14f9ee106da5526 |
|
BLAKE2b-256 | e9f285cc9d5af47ea6d1dcc8fc9170cff59a2e385c95f1ca417ecbff466fd2d6 |