We have been notified of this error, please check back later whether. This makes space for your legend but also makes a bit of space for your plot title. Download the complete Our World in Data COVID-19 dataset. This makes room for your legend.īelow, you adjusted the top margin to 2 and the right margin to 5. You can use the mar argument to adjust the white space on the bottom, left, top, or right sides of the plot. The white space is there because R is trying to plot your figure using a 1:1 aspect ratio. You want the height to be SMALLER to remove some of the white space. In the case of my plot, the aspect ratio of width:height is not right. Notice in the plot above that there is too much white space above and below the plot. One is by specifying margins for out plot. On to the pesky white space on either side of the plot. # plot ndvi with legend plot ( ndvi_classified, legend = FALSE, main = "ndvi plot", col = the_colors, axes = FALSE, box = FALSE ) # set xpd to T to allow the legend to plot OUTSIDE of the plot area par ( xpd = TRUE ) legend ( x = ndvi_classified extent xmax, y = ndvi_classified extent ymax, legend = c ( "Healthy vegetation", "Less healthy vegetation", "No vegetation" ), fill = rev ( the_colors )) # use rev to reverse the order of colors for the legend This setting will become a global setting until you clear your plot space! To clear the plot dev space programmatically, use dev.off(). Why? Because if you plot another plot in R, it will use the parameters that you set previously! In the case above you set the axes to white. Reset DevĪny time you modify the parameters, you should consider resetting the dev() space. This is because it’s no longer plotting using a square aspect ratio - you’ve adjusted that! You can experiment with different fig width and height values depending upon the aspect ratio of the plot that you are trying to print to your report. Notice that now my plot has less white space above and below the image. par ( col.axis = "white", col.lab = "white", tck = 0 ) # plot plotRGB ( all_landsat_bands_st, r = 4, b = 3, g = 2, stretch = "hist", main = "title here", axes = TRUE ) # set bounding box to white as well box ( col = "white" ) # turn all of the lines to white # adjust the parameters so the axes colors are white.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |