Skip to content

Download to CSV button #2680

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

Closed
ZooBear opened this issue Aug 1, 2020 · 2 comments
Closed

Download to CSV button #2680

ZooBear opened this issue Aug 1, 2020 · 2 comments

Comments

@ZooBear
Copy link

ZooBear commented Aug 1, 2020

Thanks for your interest in plotly.py!!

Before opening an issue, please search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Bug reports must be accompanied with a reproducible example. Please use the latest version of plotly.py in your report unless not applicable and specify if you're plotting online or offline.

Note that GitHub issues are reserved for bug reports and feature requests only. Implementation questions should be asked on community.plot.ly (tagged python) or on Stack Overflow (tagged plotly).

Comments on GitHub issues or pull requests should add content to the discussions. Approbation comments such as +1 or I would like this feature to be implemented as well will be deleted by the maintainers. Please use GitHub reactions instead.

@ZooBear ZooBear changed the title Hi, Download to CSV button Aug 1, 2020
@ZooBear
Copy link
Author

ZooBear commented Aug 1, 2020

Hi,

I am pretty new to coding in general, I wanted to put in a button to allow users to download the plotted data to a csv file. So far I found this in Javascript but have really only used Python. Has anyone done it for Python?

plotly/plotly.js#2171

Here is my code so far, I implemented a dropdown menu to try to update the data series that is plotted on the figure and would like the download button to download that data series only.

Cheers

import plotly as py
import plotly.graph_objs as go
#from plotly.offline import iplot
import chart_studio.plotly as py
import numpy as np
import chart_studio

#For config setup only
#chart_studio.tools.set_credentials_file(username='ZubairVetter', api_key='1rVxncXXbOqD6XaMWE1i')

x = np.linspace(0,0.999,250)
Co = np.logspace(14,20,7)
ko = np.linspace(0.03,0.99,33)

#Add traces, one for each slider step
data = []
for C in Co:
    for k in ko:
        trace = go.Scatter(
            visible=False,
            line=dict(color="deepskyblue", width=4),
            name="Co = "+str("{:.2E}".format(C))+', k = '+str("{:.2f}".format(k)),
            x = x,
            y=C*k*(1-x)**(k-1))
        data.append(trace)

len(data)
dictionaries = []
i=0
for trace in data:
    visibility = [False]*len(data)
    visibility[i]=True
    dictionary = dict(label = str(trace.name),
                    method = 'restyle',
                    args = ['visible',visibility])
    dictionaries.append(dictionary)
    i+=1

updatemenus = list([dict(buttons=list(dictionaries),
                         direction="down",
                         showactive=True,
                         x=0.9,
                         xanchor="right",
                         y=1.1,
                         yanchor="top")])


layout = dict(title='Crystal Segregation',
              showlegend=True,
              updatemenus=updatemenus,
              yaxis_type="log",
              width=800, height=800,
              yaxis = dict(showexponent='all',
                            exponentformat='e',
                            automargin=True,
                            title_text="Concentration cm^-3"),
              xaxis = dict(title_text="f"))

figure = dict(data=data,
            layout=layout)

#plot_url = py.plot(figure)
py.iplot(figure, filename = 'Segmentation Coefficient')
#iplot(figure)

@gvwilson
Copy link
Contributor

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

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

2 participants