---
title: "textBoxPlacement"
author: Barry Zeeberg [aut, cre]
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{textBoxPlacement}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---
Compute a non-overlapping layout of text boxes to label multiple overlain curves. For each curve, iteratively search for an adjacent x,y position for the text box that does not overlap with the other curves. If this process fails, then offsets are computed to add to the y values for each curve, that results in sufficient space to add all of the text labels.

A typical example of the improved readability is shown in Figure 1, which is taken from
multiple real-world examples of graphs generated by this package and shown in more detail in the vignette for an upcoming R package entitled "Sherlock" (discovery and analysis of concordances for search patterns in a series of texts).<br><br>

![](Figure1.jpg){width=90%}
<br>Figure 1. Example of the improved readability after processing with textBoxPlacement()

<br>The program is run as

<i>result<-positionTextBoxDriverDriverDriver(xList,yList,textList,xPos,nApprox=10,labs,sortB)</i>

where

<b>xList</b> (optional) list whose components are numeric matrices of the x values for overlain curves<br>
<b>yList</b> list whose components are numeric matrices of the y values for overlain curves<br>
<b>textList</b> (optional) list of character string texts to annotate the curves<br>
<b>xPos</b> vector of trial x positions for text boxes<br> 
<b>nApprox</b> integer number of intervals to interpolate between adjacent x data points<br>
<b>labs</b> list of labels annotating a graph<br>
&nbsp; &nbsp;<b>main</b> character string main title<br>
&nbsp; &nbsp;<b>xlab</b> character string x axis label<br>
&nbsp; &nbsp;<b>ylab</b> character string y axis label<br>
<b>sortB</b> Boolean if TRUE staggered curves reordered, with largest range curve on bottom of graph<br>

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```
