简体   繁体   中英

How to change the color palette of a plot using R and par() command?

I'm using the glmtools library for my master thesis, however, the default color palette is not aesthetically pleasing. There is not an argument about the color palette in the glmtools::plot_temp help, only says that other arguments are passed to par() . I've tried without success to change the palette. Any help?

To install glmtools

  1. Install devtools
  2. Load devtools
  3. Run devtools::install_github("GLEON/GLMr")
  4. Run devtools::install_github("USGS-R/glmtools")
  5. Load library(glmtools)

The default example is:

sim_folder <- run_example_sim(verbose = FALSE)
nc_file <- file.path(sim_folder, 'output.nc')
plot_temp(file = nc_file, fig_path = FALSE)
plot_temp(file = nc_file, fig_path = 'test_figure.png', height = 3, reference = 'surface')

And the horrible result is:

在此处输入图片说明

I'd like to use the palette terrain.colors or heat.colors

With glmtools , we had some internal functionality to pass through alternative palettes, but didn't have it exposed in the plot functions yet. Check out the latest version on github (0.14.8) . From plot_var , which you can use to plot temperature, you can pass in your own palette function. This should work with any variable you are plotting in heatmap form through glmtools package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM