Skip to content

Alienor134/SharePlot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This readme was generated automatically from a Jupyter notebook using this tutorial.

Introduction

This is a notebook directly inspired from this tutorial.
It explains how to publish online a figure generated with matplotlib and its associated data very easily using Plotly. It can be usefull to share raw data of figures from scientific papers.
Visit the original tutorial for more details !

png

Step 1: Install plotly and chart studio on a virtual environment

You can use the virtual environment of this tutorial:

conda env create -f environment.yml

Otherwise, in conda command prompt:

conda install plotly
conda install -c plotly chart-studio

Step 2: Import the data

import plotly.tools as tls

import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("data/fluo_DDAO_01_08_2022.csv")
fig = plt.figure()
plt.plot(df["Unnamed: 6"], df["Emission_600"], label = r"$emission \; (\lambda_{exc} = 600)$")

plt.plot(df["Unnamed: 2"], df["Excitation_690"], label = r"$excitation \; (\lambda_{em} = 690)$")
plt.xlabel(r"$\lambda$")
plt.ylabel('')
plt.legend()

plt.show()
fig_px = tls.mpl_to_plotly(fig)

png

C:\Users\alien\anaconda3\envs\plotly\lib\site-packages\plotly\matplotlylib\renderer.py:611: UserWarning:

I found a path object that I don't think is part of a bar chart. Ignoring.

Step 3: Import chart studio

import chart_studio
import chart_studio.plotly as py

Fill the credential file with your data (sign-up to chart-studio here, find the API key in the settings).

#username = "fill your user name here"
#api_key = "fill your API key here"

#chart_studio.tools.set_credentials_file(username=username, api_key=api_key)

Step 4: Push to chart studio

py.plot(fig_px, filename = 'excitation_DDAO', auto_open=True)

result: https://plotly.com/~Alienor134/1/

About

How to share plot data from publications online

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published