Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions metplotpy/plots/config/line_defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ xlab_offset: 2
xlab_size: 1
xlab_weight: 1
xlim: []
xlim_step: 1
xtlab_decim: 0
xtlab_horiz: 0.5
xtlab_orient: 1
Expand Down
103 changes: 63 additions & 40 deletions metplotpy/plots/line/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,43 +310,39 @@ def _draw_series(self, series: Series, x_points_index_adj: Union[list, None] =
series.idx] == 'NONE'):
error_y_visible = False


# switch x and y values for the vertical plot
error_x = {}
error_y = {}
if self.config_obj.vert_plot is True:
y_points, x_points_index_adj = x_points_index_adj, y_points
self._xaxis_limits()
self.figure.update_xaxes(autorange=False)

# add the plot

# orient the confidence interval bars based on the vert_plot setting in
# the yaml configuration file.
if self.config_obj.vert_plot:
self.figure.add_trace(
go.Scatter(x=x_points_index_adj,
y=y_points,
showlegend=self.config_obj.show_legend[series.idx] == 1,
mode=self.config_obj.mode[series.idx],
textposition="top right",
name=self.config_obj.user_legends[series.idx],
connectgaps=self.config_obj.con_series[series.idx] == 1,
line={'color': self.config_obj.colors_list[series.idx],
'width': self.config_obj.linewidth_list[series.idx],
'dash': self.config_obj.linestyles_list[series.idx]},
marker_symbol=self.config_obj.marker_list[series.idx],
marker_color=self.config_obj.colors_list[series.idx],
marker_line_color=self.config_obj.colors_list[series.idx],
marker_size=self.config_obj.marker_size[series.idx],
error_x={'type': 'data',
# Error bars for vertical plot
error_x = {'type': 'data',
'symmetric': False,
'array': series.series_points['dbl_up_ci'],
'arrayminus': series.series_points['dbl_lo_ci'],
'visible': error_y_visible,
'thickness': self.config_obj.linewidth_list[
series.idx]}
),
secondary_y=series.y_axis != 1
)
else:
self.figure.add_trace(
go.Scatter(x=x_points_index_adj,
# Error bars
error_y = {
'type': 'data',
'symmetric': False,
'array': series.series_points['dbl_up_ci'],
'arrayminus': series.series_points['dbl_lo_ci'],
'visible': error_y_visible,
'thickness': self.config_obj.linewidth_list[series.idx]
}

# add the plot
# orient the confidence interval bars based on the vert_plot setting in
# the yaml configuration file.
self.figure.add_trace(
go.Scatter(x=x_points_index_adj,
y=y_points,
showlegend=self.config_obj.show_legend[series.idx] == 1,
mode=self.config_obj.mode[series.idx],
Expand All @@ -360,17 +356,13 @@ def _draw_series(self, series: Series, x_points_index_adj: Union[list, None] =
marker_color=self.config_obj.colors_list[series.idx],
marker_line_color=self.config_obj.colors_list[series.idx],
marker_size=self.config_obj.marker_size[series.idx],
error_y={'type': 'data',
'symmetric': False,
'array': series.series_points['dbl_up_ci'],
'arrayminus': series.series_points['dbl_lo_ci'],
'visible': error_y_visible,
'thickness': self.config_obj.linewidth_list[
series.idx]}
error_x=error_x,
error_y=error_y
),
secondary_y=series.y_axis != 1
secondary_y=series.y_axis != 1
)


self.logger.info(f"Finished drawing the lines on the plot:"
f" {datetime.now()}")

Expand Down Expand Up @@ -455,25 +447,25 @@ def _adjust_for_vertical(self, x_points_index: list) -> None:
"""
Switches x and y axis (creates a vertical plot) if needed

:param x_points_index: list of indexws for the original x -axis
:param x_points_index: list of indexes for the original x -axis
"""
self.logger.info(f"Begin switching x and y axis: {datetime.now()}")
odered_indy_label = self.config_obj.create_list_by_plot_val_ordering(
ordered_indy_label = self.config_obj.create_list_by_plot_val_ordering(
self.config_obj.indy_label)
if self.config_obj.vert_plot is True:
self.figure.update_layout(
yaxis={
'tickmode': 'array',
'tickvals': x_points_index,
'ticktext': odered_indy_label
'ticktext': ordered_indy_label
}
)
)
else:
self.figure.update_layout(
xaxis={
'tickmode': 'array',
'tickvals': x_points_index,
'ticktext': odered_indy_label
'ticktext': ordered_indy_label
}
)

Expand Down Expand Up @@ -573,16 +565,47 @@ def _add_legend(self) -> None:
}
})

def _xaxis_limits(self) -> None:
"""
Apply limits on x axis if needed
especially when a vertical plot is requested

step size by default is 1 if undefined /non-existent


step size must be integer value
"""
if len(self.config_obj.parameters['xlim']) > 0:
step = round(float(self.config_obj.parameters['xlim_step']))
if step is None:
step = 1

# Convert string values to float, use numpy arange to
# generate a list of labels based on the min, max, and step values
# Round the min and max values to nearest integer
min_x= round(float(self.config_obj.parameters['xlim'][0]))
max_x= round(float(self.config_obj.parameters['xlim'][1]))
tick_labels = list(np.arange(min_x , max_x + step, step))

self.figure.update_layout(
xaxis={
'range': [min_x, max_x],
'autorange':False,
'tickvals':tick_labels}
)

def _yaxis_limits(self) -> None:
"""
Apply limits on y2 axis if needed
Apply limits on y axis if needed
"""
if len(self.config_obj.parameters['ylim']) > 0:
self.figure.update_layout(
yaxis={'range': [self.config_obj.parameters['ylim'][0],
self.config_obj.parameters['ylim'][1]],
'autorange': False})



def _y2axis_limits(self) -> None:
"""
Apply limits on y2 axis if needed
Expand Down
2 changes: 1 addition & 1 deletion metplotpy/plots/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def filter_by_fixed_vars(input_df: pd.DataFrame, settings_dict: dict) -> pd.Data

if len(valid_columns) == 0:
print(
"No columns in data match what is requested. Input dataframe will be "
"No columns in data match what is requested for filtering by fixed variable. Input dataframe will be "
"returned")
return input_df

Expand Down
Loading