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

nicer mirror plots #2

Open
chanana opened this issue Jun 7, 2023 · 0 comments
Open

nicer mirror plots #2

chanana opened this issue Jun 7, 2023 · 0 comments

Comments

@chanana
Copy link
Collaborator

chanana commented Jun 7, 2023

    def _make_mirror_plot_plotly(
        self,
        mzs_on_bottom: np.array,
        intensities_on_bottom: np.array,
        mzs_on_top: np.array,
        intensities_on_top: np.array,
        xaxis_range: Tuple[int, int],
        label_top: str = "top",
        label_bottom: str = "bottom",
        title: str = "title",
    ):
        fig = go.Figure()  # init figure

        fig.add_trace(
            go.Scatter(
                x=mzs_on_bottom,  # an array
                y=intensities_on_bottom,  # an array of same size
                name=label_bottom,
                mode="lines",
                #             customdata=intensities_ref,
                hovertemplate="intensity:%{y}<br>m/z:%{x}<br>type:bottom",
            )
        )

        # plot on top
        fig.add_trace(
            go.Scatter(
                x=mzs_on_top,
                y=intensities_on_top,
                name=label_top,
                mode="lines",
                hovertemplate="Intensity: %{y}<br>m/z:%{x}<br>type:top",
            )
        )
        fig.update_layout(
            hovermode="x unified"
        )  # allows you to look at both traces at once
        fig.update_layout(
            xaxis_range=xaxis_range,
            title=title,
            xaxis_title="m/z",
            yaxis_title="Intensity",
            #     height=400, # size of plot
            #     width=700, # size of plot
            legend_orientation="h",
            legend_x=-0.05,
            legend_y=1.1,
        )
        return fig
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