Skip to content

Commit

Permalink
wp.notebook: WorkloadNotebookPlotter: Ensure consistent ordering in l…
Browse files Browse the repository at this point in the history
…ines_px
  • Loading branch information
mrkajetanp committed Aug 21, 2023
1 parent 6072fc8 commit a4da6be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ install_requires =
pdoc==14.0.0
xarray==2023.1.0
datashader==0.15.1
kaleido==0.2.1

[options.extras_require]
all =
Expand Down
6 changes: 5 additions & 1 deletion wp/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ def gmean_bars(self, df: pd.DataFrame, x: str = 'stat', y: str = 'value', color:

return data_table

def lines_px(self, df: pd.DataFrame, x: str = 'iteration', y: str = 'value',
def lines_px(self, df: pd.DataFrame, x: str = 'iteration', y: str = 'value', sort_cols=['iteration'],
color: str = 'tag', facet_col: Optional[str] = None, facet_col_wrap: int = 2,
height: int = 600, width: Optional[int] = None, title: Optional[str] = None,
scale_y: bool = False, renderer: str = 'iframe'):
Expand All @@ -1831,12 +1831,16 @@ def lines_px(self, df: pd.DataFrame, x: str = 'iteration', y: str = 'value',
:param color: Column denoting how to split the data into lines
:param facet_col: Column denoting how to split the plot into facets
:param facet_col_wrap: Number of facet column in one row of the plot
:param sort_cols: Columns to sort the `df` by apart from `tag`
:param title: Displayed title of the plot
:param width: Plot width
:param height: Plot height
:param scale_y: Whether the y axis should maintain the same scale across facets
:param renderer: Plotly express renderer to be used
"""

df['order_tag'] = df['tag'].map(lambda x: self.ana.tags.index(x))
df = df.sort_values(by=['order_tag', *sort_cols])
fig = px.line(df, x=x, y=y, color=color, facet_col=facet_col, facet_col_wrap=facet_col_wrap,
height=height, width=width, title=title)
if not scale_y:
Expand Down

0 comments on commit a4da6be

Please sign in to comment.