# Plot conditional control over marks?

**URL:** <https://talk.observablehq.com/t/plot-conditional-control-over-marks/6499>\
**Category:** Help\
**Created:** [April 30, 2022, 5:34am UTC](https://talk.observablehq.com/t/plot-conditional-control-over-marks/6499 "2022-04-30T05:34:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/hellonearthis/32/3935_2.png) [@hellonearthis](https://talk.observablehq.com/u/hellonearthis)\
**Post date:** [April 30, 2022, 5:34am UTC](https://talk.observablehq.com/t/plot-conditional-control-over-marks/6499/1 "2022-04-30T05:34:46Z")

</div>

This there a way to have to plots conditional?

I have a check box the returns a flag but I can’t work out how to get the marks conditional.

The statement I have:

```auto
marks: [
    Plot.ruleY([120]), Plot.ruleX([-80]),
    Plot.link(data.lines, {x1: "x1", y1: "y1", x2: "x2", y2: "y2", stroke: "rgba(0,0,0,.03)"}),
    Plot.dot(data.head, dotOptions),
   ]

```

I tried:

```auto
Plot.link(() => (check=='yes')?data.lines:null, {x1: "x1", y1: "y1", x2: "x2", y2: "y2", stroke: "rgba(0,0,0,.03)"}),
// and
Plot.link(data.lines, () => (check=='yes')?{x1: "x1", y1: "y1", x2: "x2", y2: "y2", stroke: "rgba(0,0,0,.03)"},{}),

```

But no luck.

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [April 30, 2022, 6:11am UTC](https://talk.observablehq.com/t/plot-conditional-control-over-marks/6499/2 "2022-04-30T06:11:09Z")

</div>

you could try two things: one, have as data:

> Plot.link((check==‘yes’) ? data.lines : , options)

the second, to remove the mark altogether:

> check==‘yes’ ? Plot.link(data.lines, options) :

let me know if this works for you

---

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/hellonearthis/32/3935_2.png) [@hellonearthis](https://talk.observablehq.com/u/hellonearthis)\
**Post date:** [April 30, 2022, 6:59am UTC](https://talk.observablehq.com/t/plot-conditional-control-over-marks/6499/3 "2022-04-30T06:59:30Z")

</div>

Thanks, I was not checking my array correctly as checkboxes uses arrays, so I needed to do

`(check.includes('Yes'))?data.lines:[],options`

---

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [April 30, 2022, 10:38am UTC](https://talk.observablehq.com/t/plot-conditional-control-over-marks/6499/4 "2022-04-30T10:38:43Z")

</div>

> [@hellonearthis](#):
>
> Thanks, I was not checking my array correctly as checkboxes uses arrays

Perhaps you want to use `Inputs.toggle` instead, since it returns a Boolean?

---

<div class="post-metadata">

**Author:** ![visnup](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/visnup/32/305_2.png) [@visnup](https://talk.observablehq.com/u/visnup)\
**Post date:** [April 30, 2022, 3:10pm UTC](https://talk.observablehq.com/t/plot-conditional-control-over-marks/6499/5 "2022-04-30T15:10:50Z")

</div>

> [@mcmcclur](#):
>
> Perhaps you want to use `Inputs.toggle` instead, since it returns a Boolean?

I always forget this one too.

---

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/hellonearthis/32/3935_2.png) [@hellonearthis](https://talk.observablehq.com/u/hellonearthis)\
**Post date:** [April 30, 2022, 7:02pm UTC](https://talk.observablehq.com/t/plot-conditional-control-over-marks/6499/6 "2022-04-30T19:02:47Z")

</div>

> **[Toggle Input / Observable Inputs](https://observablehq.com/@observablehq/input-toggle)**
>
> A Toggle allows the user to choose one of two values, representing on or off. A Toggle is a specialized form of Checkbox. The initial value of a Toggle defaults to false. You can override this by specifying the value option. The on and off values of...

I had more that one condition so used checkboxes [here](https://observablehq.com/@hellonearthis/biological-motion-walker-demo).
