-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instructions for R/IDL/Matlab/DS9/etc. users #26
Comments
That could be useful for others, yeah. |
I thought someone already ported the colourmaps to |
Oh yeah, @calofost did that at some point. |
I used the R package ‘RColorBrewer’ to load in the RGB colour scales. Installing RColorBrewer is very simple:
Run the following code after you first download CMasher (or after every update) to create an RDS object that may be loaded into any R project. Be sure to edit the colormaps_path to the CMasher-master/cmasher/colormaps folder on your machine and the RDSfilepath to where you'd like to save the RDS object for future use.
Then, when you're ready to load the CMasher scales again, just skip the above and run the following to get the scales back (be sure to update the RDSfilepath of course):
There you go, the colour maps are all contained within the cmr_cmaps R object list. To access a specific colour map, just use the '$' operator : e.g. the rainforest is in cmr_cmaps$rainforest. Below is an example use:
There are many other ways to make colour maps, but these functions are built-into R, so no need to install further packages apart from the RColorBrewer. These should run either in RStudio or on the R command-line. They can be incorporated within scripts easily. |
@calofost Thank you very much for the example. |
I'm a regular R user so I'll contribute to this thread a bit more too - found this package from your response on SO and struggled with the fancy RDS things above, so I wanted to demo a super simple way of using these colormaps as a one-off example rather than scraping all of them at once. R's able to read a table directly from the internet so we can just grab that (assuming we have an internet connection) and import it directly. Here's some super-simple code that demos this process. It also allows you to just swap out the name to use a different one instead:
This also works with
The contribution from @calofost is very comprehensive, but sometimes folks just need a quick palette instead of all the possible options. |
Would be good to have instructions on how
R
/IDL
/Matlab
/etc users might be able to use thecmasher
colourmaps.Similarly, for certain application, this might be a good idea as well.
Perhaps in the README or in the online documentation.
The text was updated successfully, but these errors were encountered: