![]() In order to avoid repeating code we will use the following function to plot two Bessel functions in R ( J_0(x) and J_2(x)): plotl <- function(. ![]() ![]() In the following sections we will explain how to customize the most common arguments of the function. Use color, fill, size, shape, linetype, and alpha to give new titles to the corresponding. Recall that there are even more arguments you can use, but we listed the most common, so type args(legend), ?legend or help(legend) for additional information. You can change the legend title through the labs function. Horiz = FALSE # Horizontal (TRUE) or vertical (FALSE) legend Pch, # Add pch symbols to legend lines or boxesīty = "o", # Box type (bty = "n" removes the box)īg = par("bg") # Background color of the legendīox.lwd = par("lwd"), # Legend box line widthīox.lty = par("lty"), # Legend box line typeīox.col = par("fg"), # Legend box line color Legend, # Vector with the name of each groupįill, # Creates boxes in the legend with the specified colorsĬol = par("col"), # Color of lines or symbolsīorder = "black", # Fill box border color The summarized syntax of the function with the most common arguments is described in the following block: legend(x, y, # Coordinates (x also accepts keywords) The legend function allows you to add a legend to a plot in base R.
0 Comments
Leave a Reply. |