Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot DataFrame convienince method #43

Open
ckoerber opened this issue Nov 19, 2021 · 1 comment
Open

Plot DataFrame convienince method #43

ckoerber opened this issue Nov 19, 2021 · 1 comment

Comments

@ckoerber
Copy link
Owner

ckoerber commented Nov 19, 2021

Technically not directly lsqfitgui related, but it would be neat to have a wrapper for plot_gvar taking DataFrames as inputs like px.lines. Maybe, instead of having different rows and columns, also having a select widget for different groups.

@ckoerber
Copy link
Owner Author

My first thought was to provide a new px.gv_scatter along the lines of the original scatter

def gv_scatter(...):
    return make_figure(locals(), constructor=GVarScatter)

with a inherited GVarScatter which pre-processes the y to a y mean and y error.
Looking at the current go.Scatter, this needs to overload the setter of y.

Since, on __init__(...), y is stored directly in self["y"] (not using the setter), one also needs to adjust the __init__.

class GVarScatter(go.Scatter):
    
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.y = self.pop("y")
   
    @go.Scatter.y.setter
    def y(self, val):
       self["y"] = gv.mean(val)
       self["error_y"] = {"type": "data", "array": gv.sdev(val)}

This works just fine when creating figures. However, it fails for the express version. My prime suspicion is that, at some point, the dict is manipulated and I am not catching it; but I am unsure here.

I suspect a better route would be manipulating the input data frame to avoid messing around with the hidden Plotly infrastructure; and thus reduce the chance that the intended feature needs updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant