File size: 2,074 Bytes
e88abf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import solara
import seaborn as sns
import plotly.express as px
from utils import selected_template


@solara.component
def DensityHeatmap():

    with solara.Column(gap="20px", align = "stretch") as main:
        
        solara.Markdown(f"#Density Heatmap")
        # Create a heatmap using Seaborn data
        flights = sns.load_dataset("flights")
        flights

        # You can set bins with nbinsx and nbinsy
        fig1 = px.density_heatmap(flights, x='year', y='month', z='passengers', 
                                color_continuous_scale="Viridis",
                                template=selected_template.value)

        solara.Markdown(f"####Create a heatmap using Seaborn data")
        
        solara.Markdown("""
                        ```python
                            # Create a heatmap using Seaborn data
                            flights = sns.load_dataset("flights")
                            flights

                            # You can set bins with nbinsx and nbinsy
                            fig1 = px.density_heatmap(flights, x='year', y='month', z='passengers', 
                                                    color_continuous_scale="Viridis")
                        ```
                        """
                        )
        solara.FigurePlotly(fig1)



        # You can add histograms
        fig2 = px.density_heatmap(flights, x='year', y='month', z='passengers', 
                                marginal_x="histogram", marginal_y="histogram",
                                template=selected_template.value)

        solara.Markdown(f"####Add histograms")
        solara.Markdown("""
                        ```python
                            # You can add histograms
                            fig2 = px.density_heatmap(flights, x='year', y='month', z='passengers', 
                                                    marginal_x="histogram", marginal_y="histogram")
                        ```
                        """
                        )
        solara.FigurePlotly(fig2)

    return main