<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Charts",
  "identifier" : "/documentation/Charts/BarPlot",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts7BarPlotV"
  },
  "title" : "BarPlot"
}
-->

# BarPlot

Chart content that represents a collection of data using bars.

```
struct BarPlot<Content>
```

## Overview

Use `BarPlot` when you want to visualize data in the same way as with [`BarMark`](/documentation/Charts/BarMark),
but you want to visualize an entire data collection with a single plot.

You can initialize and style the plot with simple values or key paths.
Add modifiers with `KeyPath` before adding modifiers with simple values.

```
BarPlot(
    votes,
    x: .value("Party", \.party),
    y: .value("Vote count", \.voteCount)
)
.foregroundStyle(by: \.partyShapeStyle)
.cornerRadius(4)
```

## Topics

### Plotting bars from a collection

[`init(_:x:y:width:height:stacking:)`](/documentation/Charts/BarPlot/init(_:x:y:width:height:stacking:))

[`init(_:x:yStart:yEnd:width:)`](/documentation/Charts/BarPlot/init(_:x:yStart:yEnd:width:))

[`init(_:x:yStart:yEnd:width:stacking:)`](/documentation/Charts/BarPlot/init(_:x:yStart:yEnd:width:stacking:)-2mtih)

[`init(_:x:yStart:yEnd:width:stacking:)`](/documentation/Charts/BarPlot/init(_:x:yStart:yEnd:width:stacking:)-680hw)

[`init(_:xStart:xEnd:y:height:stacking:)`](/documentation/Charts/BarPlot/init(_:xStart:xEnd:y:height:stacking:)-16tou)

[`init(_:xStart:xEnd:y:height:stacking:)`](/documentation/Charts/BarPlot/init(_:xStart:xEnd:y:height:stacking:)-2x0yx)

[`init(_:xStart:xEnd:y:height:)`](/documentation/Charts/BarPlot/init(_:xStart:xEnd:y:height:))

[`init(_:xStart:xEnd:yStart:yEnd:)`](/documentation/Charts/BarPlot/init(_:xStart:xEnd:yStart:yEnd:)-48su5)

[`init(_:xStart:xEnd:yStart:yEnd:)`](/documentation/Charts/BarPlot/init(_:xStart:xEnd:yStart:yEnd:)-862wn)

[`init(_:xStart:xEnd:yStart:yEnd:)`](/documentation/Charts/BarPlot/init(_:xStart:xEnd:yStart:yEnd:)-mtdv)

[`init(_:xStart:xEnd:yStart:yEnd:)`](/documentation/Charts/BarPlot/init(_:xStart:xEnd:yStart:yEnd:)-raqh)

### Supporting types

[`body`](/documentation/Charts/ChartContent/body-swift.property)

The content and behavior of the chart content.

[`VectorizedBarPlotContent`](/documentation/Charts/VectorizedBarPlotContent)

An opaque vectorized chart content type.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)