@@ -0,0 +1,1919 @@
+%22%22%22%0AInteractive Scatter Plot and Linked Layered Histogram%0A=====================================================%0A%0AThis example shows how to link a scatter plot and a histogram%0Atogether such that clicking on a point in the scatter plot will%0Aisolate the distribution corresponding to that point, and vice versa.%0A%22%22%22%0A# category: interactive charts%0A%0A# generate fake data%0Asource = pd.DataFrame(%7B'gender': %5B'M'%5D*1000 + %5B'F'%5D*1000,%0A               'height':np.concatenate((np.random.normal(69, 7, 1000),%0A                                       np.random.normal(64, 6, 1000))),%0A               'weight': np.concatenate((np.random.normal(195.8, 144, 1000),%0A                                        np.random.normal(167, 100, 1000))),%0A               'age': np.concatenate((np.random.normal(45, 8, 1000),%0A                                        np.random.normal(51, 6, 1000)))%0A        %7D)%0A%0Aselector = alt.selection_single(empty='all', fields=%5B'gender'%5D)%0A%0Acolor_scale = alt.Scale(domain=%5B'M', 'F'%5D,%0A                        range=%5B'#1FC3AA', '#8624F5'%5D)%0A%0Abase = alt.Chart(source).properties(%0A    width=250,%0A    height=250%0A).add_selection(selector)%0A%0Apoints = base.mark_point(filled=True, size=200).encode(%0A    x=alt.X('mean(height):Q',%0A            scale=alt.Scale(domain=%5B0,84%5D)),%0A    y=alt.Y('mean(weight):Q',%0A            scale=alt.Scale(domain=%5B0,250%5D)),%0A    color=alt.condition(selector,%0A                        'gender:N',%0A                        alt.value('lightgray'),%0A                        scale=color_scale),%0A).interactive()%0A%0Ahists = base.mark_bar(opacity=0.5, thickness=100).encode(%0A    x=alt.X('age',%0A            bin=alt.Bin(step=5), # step keeps bin size the same%0A            scale=alt.Scale(domain=%5B0,100%5D)),%0A    y=alt.Y('count()',%0A            stack=None,%0A            scale=alt.Scale(domain=%5B0,350%5D)),%0A    color=alt.Color('gender:N',%0A                    scale=color_scale)%0A).transform_filter(%0A    selector%0A)%0A%0A%0Apoints %7C hists%0A

Create scatter_with_layered_histogram.py