<jupyter_start><jupyter_text>Create HTML plots with python* The purpose of this notebook is to demonstrate how to create a series of plots that can be used as part of a static webpage.* The html figures which you generate will be used in your static webpage* Source: https://plotly.com/python/linear-fits/  Take a look at the data Prior to running the next cell, you may need to install plotly in your environment. You can read about it [here](https://plotly.com/python/getting-started/) but the step is pretty simple: in a new cell, run the following code. ```! pip install plotly```<jupyter_code># import the python library
import plotly.express as px
# import a dataset about tips at restaurants
df = px.data.tips()
df.head(3)<jupyter_output><empty_output><jupyter_text>Create a simple scatter plot<jupyter_code># add changes by removing the #
scatter_fig = px.scatter(df, 
                         x='total_bill', 
#                          y='tip'
                        )
scatter_fig.show()
# save your figure
scatter_fig.write_html('docs/scatter_fig.html')<jupyter_output><empty_output><jupyter_text>Add size and color<jupyter_code># add changes by removing the #
time_fig = px.scatter(df, 
                 x="total_bill", 
                 y="tip", 
#                  color='time',
#                  opacity=0.65,
#                  size='size',
#                  color_discrete_sequence=['green', 'orange']
                )
time_fig.show()
# save your figure
time_fig.write_html('docs/time_fig.html')<jupyter_output><empty_output><jupyter_text>Create a regression plot<jupyter_code># add changes by removing the #
reg_fig = px.scatter(df, 
                 x='total_bill',
                 y='tip', 
                 trendline='ols', 
#                  trendline_color_override='red'
                )
reg_fig.show()
# save your figure
reg_fig.write_html('docs/reg_fig.html')<jupyter_output><empty_output><jupyter_text>Try comparing two groups<jupyter_code># add changes by removing the #
smoker_fig = px.scatter(df, 
                 x="total_bill", 
                 y="tip", 
#                  color="smoker", 
                 trendline="ols"
                )
smoker_fig.show()
# save your figure
smoker_fig.write_html('docs/smoker_fig.html')<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup