Skip to content

Commit f2ea825

Browse files
committed
Better altair and plotly examples
1 parent 11990de commit f2ea825

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

examples/outputs/app.py

+21-11
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,35 @@ def _():
4545
import altair as alt
4646
from vega_datasets import data
4747

48-
return (
49-
alt.Chart(data.cars())
50-
.mark_point()
51-
.encode(
52-
x="Horsepower",
53-
y="Miles_per_Gallon",
54-
color="Origin",
48+
source = data.stocks()
49+
50+
return alt.Chart(source).transform_filter(
51+
'datum.symbol==="GOOG"'
52+
).mark_area(
53+
tooltip=True,
54+
line={'color': '#0281CD'},
55+
color=alt.Gradient(
56+
gradient='linear',
57+
stops=[alt.GradientStop(color='white', offset=0),
58+
alt.GradientStop(color='#0281CD', offset=1)],
59+
x1=1, x2=1, y1=1, y2=0
5560
)
61+
).encode(
62+
alt.X('date:T'),
63+
alt.Y('price:Q')
64+
).properties(
65+
title={"text": ["Google's stock price over time"]}
5666
)
5767

5868
@output(id="plotly")
5969
@render_widget
6070
def _():
6171
import plotly.express as px
6272

63-
return px.scatter(
64-
x=np.random.randn(100),
65-
y=np.random.randn(100),
66-
color=np.random.randn(100),
73+
return px.density_heatmap(
74+
px.data.tips(),
75+
x="total_bill", y="tip",
76+
marginal_x="histogram", marginal_y="histogram"
6777
)
6878

6979
@output(id="ipyleaflet")

0 commit comments

Comments
 (0)