forked from Kaggle/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_plotly_express.py
27 lines (21 loc) · 1.27 KB
/
test_plotly_express.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import unittest
import plotly_express as px
class TestPlotlyExpress(unittest.TestCase):
def test_basic_scatter_plot(self):
gapminder = px.data.gapminder()
gapminder2007 = gapminder.query("year == 2007")
px.scatter(gapminder2007, x="gdpPercap", y="lifeExp")
def test_complex_scatter_plot(self):
gapminder = px.data.gapminder()
gapminder2007 = gapminder.query("year == 2007")
px.scatter(gapminder, x="gdpPercap", y="lifeExp",size="pop", size_max=60, color="continent", hover_name="country",
animation_frame="year", animation_group="country", log_x=True, range_x=[100,100000], range_y=[25,90],
labels=dict(pop="Population", gdpPercap="GDP per Capita", lifeExp="Life Expectancy"))
def test_choropleth_plot(self):
gapminder = px.data.gapminder()
gapminder2007 = gapminder.query("year == 2007")
px.choropleth(gapminder, locations="iso_alpha", color="lifeExp", hover_name="country", animation_frame="year",
color_continuous_scale=px.colors.sequential.Plasma, projection="natural earth")
def test_violin_plot(self):
tips = px.data.tips()
px.scatter(tips, x="total_bill", y="tip", color="smoker", trendline="ols", marginal_x="violin", marginal_y="box")