Skip to content

Commit

Permalink
Started new plot impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Oct 13, 2023
1 parent 968aaab commit caee3db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
10 changes: 5 additions & 5 deletions plot/axis.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ pub struct Axis {
pub mut:
title AxisTitle
tickmode string = 'auto'
tick0 f64
dtick f64
tickvals []f64
ticktext []string
range []f64
tick0 f64 [omitempty]
dtick f64 [omitempty]
tickvals []f64 [omitempty]
ticktext []string [omitempty]
range []f64 [omitempty]
}

// AxisTitle handles needed data to render an axis title
Expand Down
10 changes: 9 additions & 1 deletion plot/plot.v
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ pub fn (mut p Plot) add_annotation(annotation Annotation) Plot {
}

pub fn (mut p Plot) set_layout(layout Layout) Plot {
p.layout = layout
mut next_layout := layout
// Ensure that the layout range is specified correctly
if next_layout.xaxis.range.len != 2 {
next_layout.xaxis.range = []f64{}
}
if next_layout.yaxis.range.len != 2 {
next_layout.yaxis.range = []f64{}
}
p.layout = next_layout
return p
}
14 changes: 0 additions & 14 deletions plot/scripts/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ def load_json_file(file_handle):
return json.load(file_handle)


def process_layout_range(layout, axis):
"""
Ensure that the layout range is specified correctly.
"""
if f'{axis}axis' in layout:
if 'range' in layout[f'{axis}axis']:
if len(layout[f'{axis}axis']['range']) != 2:
layout[f'{axis}axis']['range'] = None


def map_trace_type_to_plotly_object(trace_type):
"""
Map vsl.plot.TraceType enum to Plotly objects.
Expand Down Expand Up @@ -90,10 +80,6 @@ def main():
# Read layout JSON file.
layout = load_json_file(args.layout)

# Ensure correct layout range specification.
for axis in ['x', 'y']:
process_layout_range(layout, axis)

# List of traces to be plotted.
plot_data = [process_trace(trace) for trace in data]

Expand Down

0 comments on commit caee3db

Please sign in to comment.