Skip to content

Commit ab8d442

Browse files
Changed match to if statements and fixed readme typo
1 parent e430bc3 commit ab8d442

6 files changed

Lines changed: 70 additions & 71 deletions

File tree

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
11 Bytes
Binary file not shown.

python/plotter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def main():
6868

6969
# Create plot based on plot subcommand, default values in Plot class will be used if argument is not specified
7070
plot_args = plot_parser.parse_args(plot_command.split())
71-
p = plot.Plot(title=" ".join(plot_args.title), xmin=plot_args.xmin, xmax=plot_args.xmax, ymin=plot_args.ymin, ymax=plot_args.ymax, xlabel=" ".join(plot_args.xlabel) if plot_args.xlabel is not None else None, ylabel=" ".join(plot_args.ylabel) if plot_args.ylabel is not None else None, opacity=plot_args.opacity,
72-
smoothing=plot_args.smoothing, bp_shift=plot_args.bp_shift, combined=plot_args.combined, color_trace=plot_args.color_trace, hide_legend=plot_args.hide_legend)
71+
p = plot.Plot(title=" ".join(plot_args.title) if plot_args.title is not None else None, xmin=plot_args.xmin, xmax=plot_args.xmax, ymin=plot_args.ymin, ymax=plot_args.ymax, xlabel=" ".join(plot_args.xlabel) if plot_args.xlabel is not None else None,
72+
ylabel=" ".join(plot_args.ylabel) if plot_args.ylabel is not None else None, opacity=plot_args.opacity, smoothing=plot_args.smoothing, bp_shift=plot_args.bp_shift, combined=plot_args.combined, color_trace=plot_args.color_trace, hide_legend=plot_args.hide_legend)
7373

7474
# Create arrays for default composite names and colors
7575
names = range(1, len(composite_commands) + 1)

python/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The `composite` and `reference-line` subcommands can be repeated for as many com
2222
plot [plot options]
2323
```
2424

25-
The `plot` subcommand takes no positional arguments, and the options specify properties for the entire plot, such as domain, range, and the axis labels. Options can also be used to specify default properties for all composites such as `opacity` and `smoothing`. This implementation of the plotter autoscales the axes to fit the largest composite by default, ignoring the `xmin`, `xmax`, `ymin`, and `ymax` options unless `--no-shirk` or `--no-resize` is specified.
25+
The `plot` subcommand takes no positional arguments, and the options specify properties for the entire plot, such as domain, range, and the axis labels. Options can also be used to specify default properties for all composites such as `opacity` and `smoothing`. This implementation of the plotter autoscales the axes to fit the largest composite by default, ignoring the `xmin`, `xmax`, `ymin`, and `ymax` options unless `--no-shrink` or `--no-resize` is specified.
2626

2727
The available options for the `plot` subcommand are:
2828

python/svgFactory.py

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -133,83 +133,82 @@ def axis(orient, scale, plot):
133133
top = plot.margins.get("top")
134134
right = plot.width - (plot.margins.get('right'))
135135
left = plot.margins.get("left")
136-
match orient:
137-
# Draw left axis
138-
case "left":
139-
axis.setAttribute("x1", str(left))
140-
axis.setAttribute("x2", str(left))
141-
axis.setAttribute("y1", str(top))
142-
axis.setAttribute("y2", str(bottom))
143-
i = top
144-
while i < bottom:
145-
tick = document.createElement("line")
146-
tick.setAttribute("y1", str(i))
147-
tick.setAttribute("y2", str(i))
148-
tick.setAttribute("x1", str(left))
149-
tick.setAttribute("x2", str(left + tickSize))
150-
axis_group.appendChild(tick)
151-
i += tickSpacing
152-
# Draw right axis
153-
case "right":
154-
axis.setAttribute("x1", str(right))
155-
axis.setAttribute("x2", str(right))
156-
axis.setAttribute("y1", str(top))
157-
axis.setAttribute("y2", str(bottom))
158-
i = top
159-
while i < bottom:
160-
tick = document.createElement("line")
161-
tick.setAttribute("y1", str(i))
162-
tick.setAttribute("y2", str(i))
163-
tick.setAttribute("x1", str(right))
164-
tick.setAttribute("x2", str(right + tickSize))
165-
axis_group.appendChild(tick)
166-
i += tickSpacing
167-
# Draw bottom axis
168-
case "bottom":
169-
axis.setAttribute("x1", str(left))
170-
axis.setAttribute("x2", str(right))
171-
axis.setAttribute("y1", str(bottom))
172-
axis.setAttribute("y2", str(bottom))
173-
i = left
174-
while i < right:
175-
tick = document.createElement("line")
176-
tick.setAttribute("y1", str(bottom))
177-
tick.setAttribute("y2", str(bottom + tickSize))
178-
tick.setAttribute("x1", str(i))
179-
tick.setAttribute("x2", str(i))
180-
axis_group.appendChild(tick)
181-
i += tickSpacing
182-
# Draw top axis
183-
case "top":
136+
# Draw left axis
137+
if (orient == "left"):
138+
axis.setAttribute("x1", str(left))
139+
axis.setAttribute("x2", str(left))
140+
axis.setAttribute("y1", str(top))
141+
axis.setAttribute("y2", str(bottom))
142+
i = top
143+
while i < bottom:
144+
tick = document.createElement("line")
145+
tick.setAttribute("y1", str(i))
146+
tick.setAttribute("y2", str(i))
147+
tick.setAttribute("x1", str(left))
148+
tick.setAttribute("x2", str(left + tickSize))
149+
axis_group.appendChild(tick)
150+
i += tickSpacing
151+
# Draw right axis
152+
elif (orient == "right"):
153+
axis.setAttribute("x1", str(right))
154+
axis.setAttribute("x2", str(right))
155+
axis.setAttribute("y1", str(top))
156+
axis.setAttribute("y2", str(bottom))
157+
i = top
158+
while i < bottom:
159+
tick = document.createElement("line")
160+
tick.setAttribute("y1", str(i))
161+
tick.setAttribute("y2", str(i))
162+
tick.setAttribute("x1", str(right))
163+
tick.setAttribute("x2", str(right + tickSize))
164+
axis_group.appendChild(tick)
165+
i += tickSpacing
166+
# Draw bottom axis
167+
elif(orient == "bottom"):
168+
axis.setAttribute("x1", str(left))
169+
axis.setAttribute("x2", str(right))
170+
axis.setAttribute("y1", str(bottom))
171+
axis.setAttribute("y2", str(bottom))
172+
i = left
173+
while i < right:
174+
tick = document.createElement("line")
175+
tick.setAttribute("y1", str(bottom))
176+
tick.setAttribute("y2", str(bottom + tickSize))
177+
tick.setAttribute("x1", str(i))
178+
tick.setAttribute("x2", str(i))
179+
axis_group.appendChild(tick)
180+
i += tickSpacing
181+
# Draw top axis
182+
elif (orient == "top"):
183+
axis.setAttribute("x1", str(left))
184+
axis.setAttribute("x2", str(right))
185+
axis.setAttribute("y1", str(top))
186+
axis.setAttribute("y2", str(top))
187+
i = left
188+
while i < right:
189+
tick = document.createElement("line")
190+
tick.setAttribute("y1", str(top))
191+
tick.setAttribute("y2", str(top + tickSize))
192+
tick.setAttribute("x1", str(i))
193+
tick.setAttribute("x2", str(i))
194+
axis_group.appendChild(tick)
195+
i += tickSpacing
196+
# Draw middle axis if plot is not combined
197+
elif (orient == "middle"):
198+
if not plot.combined == True:
184199
axis.setAttribute("x1", str(left))
185200
axis.setAttribute("x2", str(right))
186-
axis.setAttribute("y1", str(top))
187-
axis.setAttribute("y2", str(top))
201+
axis.setAttribute("y1", str(plot.yscale.get(0)))
202+
axis.setAttribute("y2", str(plot.yscale.get(0)))
188203
i = left
189204
while i < right:
190205
tick = document.createElement("line")
191-
tick.setAttribute("y1", str(top))
192-
tick.setAttribute("y2", str(top + tickSize))
206+
tick.setAttribute("y1", str(plot.yscale.get(0) - tickSize))
207+
tick.setAttribute("y2", str(plot.yscale.get(0) + tickSize))
193208
tick.setAttribute("x1", str(i))
194209
tick.setAttribute("x2", str(i))
195210
axis_group.appendChild(tick)
196211
i += tickSpacing
197-
# Draw middle axis if plot is not combined
198-
case "middle":
199-
if not plot.combined == True:
200-
axis.setAttribute("x1", str(left))
201-
axis.setAttribute("x2", str(right))
202-
axis.setAttribute("y1", str(plot.yscale.get(0)))
203-
axis.setAttribute("y2", str(plot.yscale.get(0)))
204-
i = left
205-
while i < right:
206-
tick = document.createElement("line")
207-
tick.setAttribute("y1", str(plot.yscale.get(0) - tickSize))
208-
tick.setAttribute("y2", str(plot.yscale.get(0) + tickSize))
209-
tick.setAttribute("x1", str(i))
210-
tick.setAttribute("x2", str(i))
211-
axis_group.appendChild(tick)
212-
i += tickSpacing
213212
axis_group.setAttribute("stroke", "black")
214213
axis_group.appendChild(axis)
215214
return axis_group

0 commit comments

Comments
 (0)