# Pandas Dataframe by Example: Plot Examples with Pyplot

Last updated:Table of Contents

- Sample data for examples
- Simplest possible scatter plot
- Simplest possible line plot
- Save plot to file
- Stacked bar plot with groupby data

WIP Alert This is a work in progress. Current information is correct but more content may be added in the future.

You need to have the

matplotlibmodule installed for this!

### Sample data for examples

*This is what our sample dataset looks like*

You can plot data *directly* from your DataFrame using the `plot()`

method:

## Simplest possible scatter plot

```
# a scatter plot comparing num_children and num_pets
df.plot(kind='scatter',x='num_children',y='num_pets')
```

*You can plot a scatter plot directly from dataframe columns using*

`df.plot`

## Simplest possible line plot

```
# a simple line plot
df.plot(kind='line',x='name',y='age')
```

*By changing the*

`'kind'`

parameter to 'line', you get a line plot instead.## Save plot to file

```
TODO
```

## Stacked bar plot with groupby data

```
TODO
```

### References

- A lot of other types of plot are available. See all of them here