Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instructions for R/IDL/Matlab/DS9/etc. users

See original GitHub issue

Would be good to have instructions on how R/IDL/Matlab/etc users might be able to use the cmasher colourmaps. Similarly, for certain application, this might be a good idea as well. Perhaps in the README or in the online documentation.

  • R (3ce67f9)
  • IDL
  • DS9

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

calofostcommented, Oct 28, 2020

I used the R package ‘RColorBrewer’ to load in the RGB colour scales. Installing RColorBrewer is very simple:

#If RColorBrewer is not already install, install it with:

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.

#Load CMasher colours - must cite CMasher2020 - (i.e. van der Velden 2020)

#Loading RColorBrewer package.

#Edit following paths:

#Looking up the names of the scales and location of the _norm.txt files:
cmr_cmaps_files=list.files(path=colormaps_path, recursive=TRUE, all.files=TRUE,, pattern='_norm.txt')
cmr_cmaps_list=list.dirs(path=colormaps_path, full.names=FALSE)
cmr_cmaps_list=cmr_cmaps_list[2:length(cmr_cmaps_list)] #Removing "." from the list of directories.

#Loading all colour scales and adding them to a list object containing all scales called cmr_cmaps..
for (cmr_cmap in cmr_cmaps_list) {
  assign(cmr_cmap, rgb(red=CM_RGB$R, green=CM_RGB$G, blue=CM_RGB$B))
  cmr_cmaps[[cmr_cmap]] = get(cmr_cmap)

#Create RDS file containing all CMasher colormaps into a single object:
saveRDS(cmr_cmaps,file=paste0(RDSfilepath, '/', 'cmr_cmaps.RDS'))

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):

#Easy to load using the RDS object back into any R project using:
cmr_cmaps=readRDS(file=paste0(RDSfilepath, '/', 'cmr_cmaps.RDS'))

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:

#Example use (volcano is an example dataset pre-loaded in every R installation):
layout(matrix(c(1,2),1, 2, byrow = TRUE), widths=c(3,1))
image(volcano, col = cmr_cmaps$rainforest, main = "rainforest")
image(y=seq(from=min(volcano),to=max(volcano),by=(diff(range(volcano)))/length(cmr_cmaps$rainforest)),z=t(1:length(cmr_cmaps$rainforest)), col=cmr_cmaps$rainforest, axes=FALSE, main="variable name", cex.main=.8)

This is the output plot: image

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.

1313ecommented, Oct 28, 2020

@calofost Thank you very much for the example. I will add it to the documentation as soon as possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DS9 Users Manual - SAOImageDS9
The DS9 Users Manual leads the user step-by-step through many features of ds9, such as data binning and contours. For an in-depth description...
Read more >
T5220 ilom user guide, My music season 2 episode 5, Nissan skyline godzilla, ... Unterrichtswerke, Simon mayo team radio 2, Anfis matlab source...
Read more >
Quick Start Guide: Campus-Wide License
This guide includes detailed instructions for both administrators and end users. Deployment for Individuals (Through MATLAB Portal).
Read more >
Pan fried swordfish recipe, Kbifq, Calculate inter rater reliability excel, Landshire sandwiches jobs, Lumix tz30 user manual, Weather forecast brundage id, ...
Read more >
Debian -- Software Packages in "bullseye", Subsection doc
Secure and unified container for user passwords. libkf5wayland-doc (4:5.78.0-2): Qt library wrapper for Wayland libraries (documentation); libkf5widgetsaddons- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found