Skip to content

Missing units prevent plotting #128

@DunklesArchipel

Description

@DunklesArchipel

When no units are specified in the fields of the entry, the plot method in entry() returns an error

Cell In[7], [line 2](vscode-notebook-cell:?execution_count=7&line=2)
      1 entry = Entry.from_csv(file, header_lines=[2](vscode-notebook-cell:?execution_count=7&line=2))
----> 2 entry.plot()

File d:\github\echemdb\electrochemistry-data\.pixi\envs\dev\Lib\site-packages\unitpackage\entry.py:780, in Entry.plot(self, x_label, y_label, name)
    762 fig = plotly.graph_objects.Figure()
    764 fig.add_trace(
    765     plotly.graph_objects.Scatter(
    766         x=self.df[x_label],
   (...)    770     )
    771 )
    773 fig.update_layout(
    774     template="simple_white",
    775     showlegend=True,
    776     autosize=True,
    777     width=600,
    778     height=400,
    779     margin={"l": 70, "r": 70, "b": 70, "t": 70, "pad": 7},
--> [780](file:///D:/github/echemdb/electrochemistry-data/.pixi/envs/dev/Lib/site-packages/unitpackage/entry.py:780)     xaxis_title=f"{x_label} [{self.field_unit(x_label)}]",
    781     yaxis_title=f"{y_label} [{self.field_unit(y_label)}]",
    782 )
    784 fig.update_xaxes(showline=True, mirror=True)
    785 fig.update_yaxes(showline=True, mirror=True)
...
   (...)    365 
    366     """
--> [367](file:///D:/github/echemdb/electrochemistry-data/.pixi/envs/dev/Lib/site-packages/unitpackage/entry.py:367)     return self.mutable_resource.schema.get_field(field_name).custom["unit"]

KeyError: 'unit'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions