Plotting Yacht Polars with R

Predicting the performance of sailing yachts under varying conditions of wind and sail is enabled by a circular plot commonly referred to as a polar diagram. This visualisation is useful to compare yachts, plan sailing strategies for racing and to determine sail configurations for specific wind conditions.

This example uses log book data from my own sailing yacht, Sedoza Sakona a Liberty 458 cutter rigged sloop. You can check her out here. You can also derive yacht polars in near real time using data from onboard systems too.

This example is self contained. The sample data is included in the git repo. This simplistic approach has enabled me to derive polars when at sea and when out of range of internet connectivity. Here’s a sample of the polar data that R is using to plot our Polar diagram

TWA TWS VMG Jib(%) Main% Date Configuration
125 7 5 0 100 25Jul2014 As built config

Here’s the R code.

### R script for plotting yacht performance polars
## Preconditions
# place polars.csv in the same directory as this script.
Tested on a Mac running R 3.3.3 with the following libraries

## Include R libraries
library(ggplot2)
library(ggrepel)
library(lubridate)
library(dplyr)
library(scales)

## Create plot ready data frames

## Source data
polars <- read.csv("polars.csv") # grab the polar data with columns
TWA, TWS, VMG not SOG and sailplan(jib, main, staysail, spinaker) as
% in seperate columns, Date (date) and Vessel Configuration (text) by
date
polars <- data.frame(polars, fix.empty.names = TRUE, stringsAsFactors
= TRUE) # build the polars df
str(polars) # check it was read and the df has data

## The plot
p <- ggplot(polars, aes(x=TWA, y=VMG, color=Date)) +
geom_point() +
geom_point(aes(size=TWS)) +
coord_polar() +
scale_x_continuous(limits=c(0,360), breaks=seq(0, 360, by=45),
minor_breaks=seq(0, 360, by=15)) +
scale_y_continuous(limits=c(0,max(polars$VMG)), breaks=seq(0, 12, by=1))
+
ggtitle("Yacht Polars")
p
ggsave("yacht-polars.png", device = NULL, dpi = 300)

Yacht Polar Diagram

Continue reading articles in my Sailing series