Put color bar legend in the right plot margin.
Put color bar legend in the right-hand side margin of an existing plot.
Gives the range of z values to which the colors specified
Gives the range of colors to use. To keep multiple plots
consistent in terms of the colors assigned to various values, keep
This function works best when there is only one plot on the
device, in which case the margin space is straightforward (no
etc. Originially, this function also assumed that the user had
already finished making the main portion of the plot before adding the
legend; i.e., the user should add the legend last. While the
author believes that this issue has been resolved, the author
recommends that the user avoid changing the main plot after using this
legend command. This function alters the
to draw the legend, and trying to reset them properly is not
Puts vertical color bar legend to the right of the plot.
As noted in the help for
image.plot in the
fields package, putting a legend on a plot is harder than it might
seem. The user may have to experiment with this function a bit to get
it to work well for a specific application. The user may also want to
try the previously mentioned
in the fields package. (To just add the legend using
image.plot, use “legend.only=TRUE”.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
## Plot ozone at each location using colors from rainbow.colors ## and differently-sized points. Add a legend using function ## vertical.image.legend (included in this package). data(ozone1) col.rng <- rev(rainbow(n=10, start=0, end=4/6)) z.rng <- c(40, 90) plot3d.points(x=ozone1$longitude, y=ozone1$latitude, z=ozone1$daily.max, xlab="longitude", ylab="latitude", zlim=z.rng, col=col.rng, cex.min=0.5, cex.max=1.5) ## To verify, label the points with their concentrations. text(ozone1$longitude, ozone1$latitude+0.15, ozone1$daily.max, cex=0.7) ## If maps package is available, put on state lines. if (require("maps")) map("state", add=TRUE, col="lightgray") ## Put on legend. vertical.image.legend(col=col.rng, zlim=z.rng)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.