While working on a dataset it is important to check the distribution of the data. Obviously, for most of humans it is difficult to visualize the data in more than 3 dimensions
Viz is important to understand the data and to show results. We have already seen there are some basinc viz functionalities in Pandas.
Now we'll discover two of the most know viz libraries in Python:
- Pandas viz
- Matplotlib
- Plotly
Pandas viz is pratique: rapid plot, relies on Matplotlib. (check matplotlib doc sometimes not all params are detailed in pandas doc)
The goal of this plot is to learn to use Matplotlib to plot data. As you know, Matplotlib is the underlying library used by Pandas. It provides more options to plot custom visualizations. Howerver, most of the plots we will create with Matplotlib can be reproduced with Pandas' `.plot()`.
1. Reproduce this plot. We assume the datapoints have integers coordinates.
1. Reproduce this plot. We assume the data points have integers coordinates.
![alt text][logo_ex3]
@ -125,61 +119,61 @@ The plot has to contain:
- name on x-axis and y-axis
- x-axis and y-axis are limited to [1,8]
- **style**:
- red dashdot line with a width of 3
- blue circles with a size of 12
- red dashdot line with a width of 3
- blue circles with a size of 12
## Correction
1. This question is validated if the plot reproduces the plot in the image and respect those criterias
1. This question is validated if the plot reproduces the plot in the image and respect those criteria
The goal of this plot is to learn to use Matplotlib to plot different lines in the same plot on different axis using `twinx`. This very useful to compare variables in different ranges.
The goal of this exerice is to learn to use Matplotlib to create subplots.
The goal of this exercise is to learn to use Matplotlib to create subplots.
1. Reproduce this plot using a **for loop**:
@ -207,7 +202,7 @@ The plot has to contain:
## Correction
1. The question is validated if the plot reproduces the image and the given criterias:
1. The question is validated if the plot reproduces the image and the given criteria:
The plot has to contain:
@ -225,6 +220,7 @@ The plot has to contain:
Check that the plot has been created with a for loop.
# Exercise 6 Plotly 1
Plotly has evolved a lot in the previous years. It is important to **always check the documentation**.
Plotly comes with a high level interface: Plotly Express. It helps building some complex plots easily. The lesson won't detail the complex examples. Plotly express is quite interesting while using Pandas Dataframes because there are some built-in functions that leverage Pandas Dataframes.
@ -233,7 +229,7 @@ The plot outputed by Plotly is interactive and can also be dynamic.
The goal of the exercise is to plot the price of a company. Its price is generated below.
```
```python
returns = np.random.randn(50)
price = 100 + np.cumsum(returns)
@ -258,21 +254,21 @@ The plot has to contain:
https://plotly.com/python/time-series/e
## Correction
1. This question is validated if the plot is in the image is reproduced using Plotly express given those criterias:
1. This question is validated if the plot is in the image is reproduced using Plotly express given those criteria:
The plot has to contain:
- a title
- x-axis name
- yaxis name
![alt text][logo_ex6]
[logo_ex6]: images/day03/w1day03_ex6_plot1.png "Time series ex6"
2.This question is validated if the plot is in the image is reproduced using `plotly.graph_objects` given those criterias:
2.This question is validated if the plot is in the image is reproduced using `plotly.graph_objects` given those criteria:
The plot has to contain:
@ -290,11 +286,12 @@ The goal of this exercise is to learn to use Plotly to plot Box Plots. It is t i
Let us generate 3 random arrays from a normal distribution. And for each array add respectively 1, 2 to the normal distribution.
```
```python
y0 = np.random.randn(50)
y1 = np.random.randn(50) + 1 # shift mean
y2 = np.random.randn(50) + 2
```
1. Plot in the same Figure 2 box plots as shown in the image. In this exercise the style is not important.
![alt text][logo_ex7]
@ -305,11 +302,12 @@ The plot has to contain:
- the title
- the legend
https://plotly.com/python/box-plots/
## Correction
1. This question is validated if the plot is in the image is reproduced given those criterias:
1. This question is validated if the plot is in the image is reproduced given those criteria: