# Adding Line Segments to Scatter Plots or XY Plots

## Recommended Posts

• Seeq Team

Sometimes when looking at an xy plot, it can be helpful to use lines to designate regions of the chart that you'd like users to focus on. In this example, we want to draw a rectangle on the xy plot showing the ideal region of operation, like below. We can do this utilizing Seeq's ability to display formulas overlaid against an xy plot.

1. For this first step, we will create a ~horizontal line on the scatter plot at y=65. This can be achieved using a y=mx+b formula with a very small slope, and a y-intercept of 65. The equation for this "horizontal" line on the xy plot is:

`0.00001*\$x+65`

2. If we want to restrict the line to only the segment making the bottom of our ideal operation box, we can leverage the within function in formula to clip the line at values we specify. Here we add to the original formula to only include values of the line between x=55 and 5=60.

```(0.00001*\$x+65)
.within(\$x>55 and \$x<60)```

3. Now let's make the left side of the box. A similar concept can be applied to create a vertical line, only a very large positive or negative slope can be used. For our "vertical" line at x=55, we can use the following formula. Note some adjustment of the y-axis scale may be required after this step.

`(-10000*(\$x-55))`

4. To clip a line into a line segment by restricting the y values, you can use the max and min functions in Formula, combined with the within function. The following formula is used to achieve the left side boundary on our box:

```(-10000*(\$x-55))
.max(65)
.min(85)
.within(\$x<55.01 and \$x>54.99) ```

The same techniques from steps 1-4 could be used to create the temperature and wet bulb max boundaries.

Formula for max temp boundary:

`(0.00001*\$x+85).within(\$x>55 and \$x<60)`

Formula for max wet bulb boundary:

```(-10000*(\$x-60))
.max(65)
.min(85)
.within(\$x<60.01 and \$x>59.99)```

• 3
##### Share on other sites
• 4 weeks later...

Thanks for sharing, I'd not figured out a vertical line method. For horizontal I'd used:

`55*\$x/\$x`

## Create an account

Register a new account