File size: 3,998 Bytes
42ee455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""Correlation charts."""

import vizro.models as vm
import vizro.plotly.express as px

from pages._factories import column_and_line_factory, connected_scatter_factory
from pages._pages_utils import PAGE_GRID, gapminder, iris, make_code_clipboard_from_py_file

scatter = vm.Page(
    title="Scatter",
    path="correlation/scatter",
    layout=vm.Layout(grid=PAGE_GRID),
    components=[
        vm.Card(
            text="""

            #### What is a scatter chart?

            A scatter plot is a two-dimensional data visualization using dots to represent the values obtained for two
            different variables - one plotted along the x-axis and the other plotted along the y-axis.

             

            #### When should I use it?

            Use scatter plots when you want to show the relationship between two variables. Scatter plots are sometimes
            called _Correlation plots_ because they show how two variables are correlated. Scatter plots are ideal when
            you have paired numerical data and you want to see if one variable impacts the other. However, do remember
            that correlation is not causation. Make sure your audience does not draw the wrong conclusions.
        """
        ),
        vm.Graph(figure=px.scatter(iris, x="sepal_width", y="sepal_length", color="species")),
        make_code_clipboard_from_py_file("scatter.py"),
    ],
)

connected_scatter = connected_scatter_factory("correlation")

scatter_matrix = vm.Page(
    title="Scatter matrix",
    path="correlation/scatter-matrix",
    layout=vm.Layout(grid=PAGE_GRID),
    components=[
        vm.Card(
            text="""

            #### What is a scatter matrix?

            A scatter matrix, also known as a SPLOM chart, is a multi-dimensional data visualization that displays
            scatter plots for every pair of variables in a dataset. Each scatter plot is positioned in a matrix format,
            where rows and columns represent different variables.

             

            #### When should I use it?

            Use a scatter matrix when you want to explore relationships between multiple pairs of variables
            simultaneously. They are particularly useful for identifying correlations, patterns, and potential outliers
            within a dataset containing multiple numerical variables. Carefully select the most relevant variables to
            ensure clarity and readability of the chart.
        """
        ),
        vm.Graph(
            figure=px.scatter_matrix(iris, dimensions=["sepal_length", "sepal_width", "petal_length", "petal_width"])
        ),
        make_code_clipboard_from_py_file("scatter_matrix.py"),
    ],
)

bubble = vm.Page(
    title="Bubble",
    path="correlation/bubble",
    layout=vm.Layout(grid=PAGE_GRID),
    components=[
        vm.Card(
            text="""

            #### What is a bubble chart?

            A bubble chart is a type of data visualization that displays three dimensions of data. Each point on the
            chart is represented by a bubble, where the x-axis and y-axis denote two of the data dimensions, and the
            size of the bubble represents the third dimension.

             

            #### When should I use it?

            Use a bubble chart when you want to explore and compare relationships between three variables
            simultaneously. They are particularly useful for identifying patterns, trends, and outliers in
            multi-dimensional data. Bubble charts can help you visualize the impact of a third variable,
            providing deeper insights than a standard scatter plot.
        """
        ),
        vm.Graph(figure=px.scatter(gapminder.query("year==2007"), x="gdpPercap", y="lifeExp", size="pop", size_max=60)),
        make_code_clipboard_from_py_file("bubble.py"),
    ],
)

column_and_line = column_and_line_factory("correlation")
pages = [scatter, connected_scatter, scatter_matrix, bubble, column_and_line]