> For the complete documentation index, see [llms.txt](https://larhues-personal-organization.gitbook.io/intro-to-data-visualization/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://larhues-personal-organization.gitbook.io/intro-to-data-visualization/exercises-and-examples/the-gapminder-dataset/exploring-the-data.md).

# Exploring the Data

Let's start with the first use case, looking at Life Expectancy. We are interested in thinking about the factors that influence Life Expectancy. Looking at the columns dataset, and considering our use case, we can ask questions related to:

* **Economics**: What is the correlation between life expectancy and GDP per capita?
* **Time Series**: Does life expectancy change (increase/decrease) over time? Are the patterns consistent by region?
* **Regions**: Are there geographic / regional patterns in life expectancy?

Let's explore the first questions, and you can explore the second two questions on your own.

***

#### **Q1: Economics**

Let's create some visualizations related to Life Expectancy and GDP.

**Life expectancy and GDP**

```python
import plotly.express as px

fig = px.scatter(
    data_frame=df = px.data.gapminder(),
    x="lifeExp",
    y="gdpPercap",
    
)
fig.show()
```

Output:

<figure><img src="https://2216244047-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCGIx3TUapGPVDCUiMvhC%2Fuploads%2FDgOgYBxhjKWRHVx1MlKJ%2Fq1_scatter.png?alt=media&amp;token=619ba0aa-7a32-46c0-8637-b0455b2fc201" alt=""><figcaption></figcaption></figure>

Let's add a title and just look at `Year = 2007`.

<pre class="language-python"><code class="lang-python"><strong>import plotly.express as px
</strong>
fig = px.scatter(
    data_frame=df[df['year'] == 2007],
    x="lifeExp",
    y="gdpPercap",
    color="continent",
    title="Life Expectancy v GDP: 2007"
    
)
fig.show()
</code></pre>

Output

<figure><img src="https://2216244047-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCGIx3TUapGPVDCUiMvhC%2Fuploads%2FZKKDs7RaVY51H00oEQW1%2Fq1_scatter_continent.png?alt=media&amp;token=676cbf8c-7a47-48c4-a2a3-b70f886b3245" alt=""><figcaption></figcaption></figure>

### Time Series

There are several other options for charts looking at Life Expectancy and GDP per capita that explore how this effect changes over time.

* What about a visualization with pooled data, not just 2007? What about different colors by year?
* What about a visualization of the relationship for each continent?
* Does it look different to include a regression plot?

### Regions

* What is the correlation between life expectancy and GDP per capita?
* **Time Series**: Does life expectancy change (increase/decrease) over time? Are the patterns consistent by region?
* **Regions**: Are there geographic / regional correlations?
