<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Charts",
  "identifier" : "/documentation/Charts/PointMark/init(x:y:)-9hppd",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts9PointMarkV1x1yAcA14PlottableValueVyxG_14CoreFoundation7CGFloatVSgtcAA0D0Rzlufc"
  },
  "title" : "init(x:y:)"
}
-->

# init(x:y:)

Creates a point mark that plots a value on x with fixed y position.

```
nonisolated init<X>(x: PlottableValue<X>, y: CGFloat? = nil) where X : Plottable
```

## Parameters

`x`

The value plotted with x.

`y`

The y position.  If `y` is `nil`, the bar will be centered vertically by default.

## Discussion

### Discussion

Use this initializer to plot a property with x:

```swift
Chart(data) {
    PointMark(
        x: .value("Weight", $0.weight)
    )
}
```

![Horizontal point chart with weight plotted to the x-axis. There are 9 points at: 22, 24, 18, 22, 30, 27, 20, 14, 29.](images/com.apple.Charts/PointMarkSwift.PointMarkHorizontalPointChart@2x.png)

For more background, see the first example used in [`PointMark`](/documentation/Charts/PointMark) which shows the structure that contains the `weight` property.

---

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)