<jupyter_start><jupyter_text>JupyterLab Chart EditorThis example relies on the `jupyterlab-chart-editor` extension (https://github.com/plotly/jupyterlab-chart-editor)  Imports<jupyter_code>import plotly.graph_objs as go
import plotly.io as pio

import pandas as pd<jupyter_output><empty_output><jupyter_text>Load DatasetLoad gapminder dataset for 1982<jupyter_code>data = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv")
df_1982 = data[data['year']==1982]
df_1982 = df_1982.sort_values(['continent', 'country'])
df_1982.head()<jupyter_output><empty_output><jupyter_text>Create empty FigureWidget<jupyter_code>fig = go.FigureWidget()
fig<jupyter_output><empty_output><jupyter_text>Add scatter trace per continent<jupyter_code>for continent, continent_df in df_1982.groupby('continent'):
    fig.add_scatter(x=continent_df.lifeExp,
                    y=continent_df.gdpPercap,
                    marker={'size': continent_df['pop'].tolist(), 'sizemode': 'area', 'sizeref': 200000},
                    mode='markers',
                    text=continent_df.country,
                    name=continent)<jupyter_output><empty_output><jupyter_text>Write figure to json file<jupyter_code>pio.write_json(fig, 'out/gapminder.plotly.json')<jupyter_output><empty_output><jupyter_text>Edit with JupyterLab chart editorRight click on `out/gapminder.plotly.json` and "Open With -> PlotlyEditor"Make edits to the chart to add a title, axis titles, trace coloring, annotations, etc.  Then use "File -> Save As" to save modified figure as `out/gapminder-styled.plotly.json  Read modified figure back into Python<jupyter_code>fig_styled = pio.read_json('out/gapminder-styled.plotly.json',
                           output_type='FigureWidget')
fig_styled<jupyter_output><empty_output><jupyter_text>Save edited figure to HTML<jupyter_code># Save as standalone html
from plotly.offline import plot
plot(fig_styled, filename='out/gapminder-styled.html', auto_open=False);<jupyter_output><empty_output><jupyter_text>Save edited figure as pdf<jupyter_code># Save as image
pio.write_image(fig_styled, 'out/gapminder-styled.pdf')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11121281464530892, 'fraction_numerical': 0.015560640732265447, 'mean_word_length': 5.624242424242424, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '27269', 'license': 'MIT', 'n_tokens_mistral': 790, 'n_tokens_neox': 742, 'n_words': 131, 'path': 'notebooks/4. Chart Editor.ipynb', 'repo_name': 'plotly/plotlylab', 'size': '2185'}