Giter Site home page Giter Site logo

Palette specification about ouch HOT 8 CLOSED

kingaa avatar kingaa commented on August 22, 2024
Palette specification

from ouch.

Comments (8)

kingaa avatar kingaa commented on August 22, 2024

But by default, palette=rainbow. See

ouch/R/plot.R

Line 150 in 3dec2ce

palette = rainbow,

from ouch.

mbutler808 avatar mbutler808 commented on August 22, 2024

Yes, I saw that. Sorry. I guess we want default palette = NULL, and if (is.null(palette)) palette=rainbow( length(levs)) ?

from ouch.

mbutler808 avatar mbutler808 commented on August 22, 2024

Or is

if (palette==rainbow) palette <- rainbow(length(levs))

a valid check? Otherwise use the vector specified ?

from ouch.

mbutler808 avatar mbutler808 commented on August 22, 2024

So I tried changing the default palette = rainbow in an tree plot, and it had no effect. I thought that rainbow(length(levs)) would return a vector of hex color codes, so I tried writing a dummy function 'mypal' that would return the same type of object:

col2hex <- function(cc) {rgb(col2rgb(cc)[1], col2rgb(cc)[2], col2rgb(cc)[3], maxColorValue=255)}

mypal <- function(x){return(c(col2hex("black"), col2hex("blue"), col2hex("purple")))}

data(bimac)
tree <- with(bimac,ouchtree(node,ancestor,time/max(time),species))

plot(tree,regimes=bimac["OU.LP"], palette=mypal)   # no effect
plot(tree,regimes=bimac["OU.LP"], palette= c("black", "blue", "purple"))   # no effect

I don't understand why specifying palette does nothing. It is a parameter to the plot function. Is it masked some how?

from ouch.

kingaa avatar kingaa commented on August 22, 2024

Are you running the plotting branch? It works for me. Will merge the plotting branch in when we are finished with it.

from ouch.

kingaa avatar kingaa commented on August 22, 2024

I've merged these changes to the master branch. Please have a look.

from ouch.

mbutler808 avatar mbutler808 commented on August 22, 2024

Thank you! It does work. Sorry for the delay.
Had figured out how to install from branch yesterday, lol. But I didnʻt have time to reply. It works but itʻs kind of awkward:

plot(tree, regimes=bimac["OU.LP"], palette=function(x)return(c("blue", "turquoise", "pink")))

Was the simplest implementation I could find. How about if we could also supply a vector? in tree.plot.internal:

  ifelse (class(palette)=="function", palette(length(levs)), palette) 

Then a vector could be supplied.

from ouch.

kingaa avatar kingaa commented on August 22, 2024

Will do.

from ouch.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.