# Bar Charts

A bar plot presents categorical data with rectangular bars with lengths proportional to the values that they represent.

## Examples

### Bar plot on Series

```markup
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <script src="https://cdn.jsdelivr.net/npm/danfojs@1.2.0/lib/bundle.min.js"></script>
    <title>Document</title>
</head>

<body>

    <div id="plot_div"></div>
    <script>

        const s = new dfd.Series([1, 3, 2, 6, 10, 34, 40, 51, 90, 75])
        s.plot("plot_div").bar()

    </script>
</body>

</html>
```

![](https://3251798050-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB05JeHIrR5pfcM-_7L%2Fuploads%2Fgit-blob-3840faa177735e7334659f9454b20de0f9d9e6db%2Fnewplot%20\(6\).png?alt=media\&token=5dc41311-4dce-422c-a889-63d2592d3d55)

### Bar plot on DataFrame

```markup
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <script src="https://cdn.jsdelivr.net/npm/danfojs@1.2.0/lib/bundle.min.js"></script>
</head>

<body>

    <div id="plot_div"></div>
    <script>

        const df = new dfd.DataFrame({'pig': [20, 18, 489, 675, 1776],
                               'horse': [4, 25, 281, 600, 1900]}, {index: [1990, 1997, 2003, 2009, 2014]})
        df.plot("plot_div").bar()

    </script>
</body>

</html>
```

![](https://3251798050-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB05JeHIrR5pfcM-_7L%2Fuploads%2Fgit-blob-1c17ee4b2ba736c66772cde18074f84dfc0a63ab%2Fnewplot%20\(7\).png?alt=media\&token=15ae1ab4-567d-4b04-bb97-24b96e04c91e)

{% hint style="info" %}
To customize plots, see the [Customizing your plot page](https://danfo.jsdata.org/api-reference/plotting/configuring-your-plots)
{% endhint %}
