65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
import plotly.express as px
|
|
import pandas as pd
|
|
df = px.data.gapminder()
|
|
df2007 = df.query("year == 2007")
|
|
print(df2007.head())
|
|
fig = px.scatter(df2007,
|
|
x="gdpPercap",
|
|
y="lifeExp",
|
|
color="continent",
|
|
title="A Plotly Express Figure",
|
|
size='pop',
|
|
size_max= 60
|
|
)
|
|
fig = px.scatter(df2007,
|
|
x="gdpPercap",
|
|
y="lifeExp",
|
|
color="continent",
|
|
title="A Plotly Express Figure",
|
|
size='pop',
|
|
size_max= 60,
|
|
facet_col='continent',
|
|
log_x=True
|
|
)
|
|
fig = px.scatter(df,
|
|
x="gdpPercap",
|
|
y="lifeExp",
|
|
color="continent",
|
|
title="A Plotly Express Figure",
|
|
size='pop',
|
|
size_max= 60,
|
|
# facet_col='continent',
|
|
log_x=True,
|
|
animation_frame='year',
|
|
animation_group='country',
|
|
# range_x=[100,10000],
|
|
range_y=[25,90]
|
|
)
|
|
|
|
fig.show()
|
|
|
|
import plotly.express as px
|
|
|
|
df = px.data.iris()
|
|
print(df.columns)
|
|
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", title="A Plotly Express Figure")
|
|
fig = px.scatter_matrix(df, dimensions=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'],
|
|
color='species')
|
|
fig.show()
|
|
|
|
import plotly.express as px
|
|
|
|
import pandas as pd
|
|
import numpy as np
|
|
np.random.seed(1)
|
|
|
|
N = 100000
|
|
|
|
df = pd.DataFrame(dict(x=np.random.randn(N),
|
|
y=np.random.randn(N)))
|
|
|
|
fig = px.scatter(df, x="x", y="y", render_mode='webgl')
|
|
|
|
fig.update_traces(marker_line=dict(width=1, color='DarkSlateGray'))
|
|
|
|
fig.show() |