Giter Club home page Giter Club logo

Comments (8)

averissimo avatar averissimo commented on August 30, 2024

You want to control the colors on each curve? try this:

p1 <- autoplot(survival_obj)
p1 <- p1 + scale_colour_manual(values = c('indianred2','seagreen'))

I was having the same problem and when debugging found that it uses geom_step function and this is how to control the colors :)

Despite all this, I think the implementation on ggfortify should be more clear on that option or corrected.

Cheers

from ggfortify.

sinhrks avatar sinhrks commented on August 30, 2024

@averissimo thx for the reply. It is correct that we should specify multi colors like ggplot2 does.
Maybe better to update the doc.

@DarioS Sorry to late reply, I missed the notification.

from ggfortify.

DarioS avatar DarioS commented on August 30, 2024

I think that it would be better to provide abstraction of this to the end-user, as the function currently tries to do unsuccessfully. The underlying ggplot2 framework should be hidden away where possible.

from ggfortify.

sinhrks avatar sinhrks commented on August 30, 2024

OK, will consider the fix.

from ggfortify.

lselzer avatar lselzer commented on August 30, 2024

@DarioS I'm guessing that you want to make all lines red regardless of which group they are. Am I correct?

from ggfortify.

DarioS avatar DarioS commented on August 30, 2024

Actually, it would be desirable to specify one colour per factor level. I only used "red" because the surv.colour option doesn't allow a vector of values.

> library(survival)
> autoplot(survfit(Surv(time, status) ~ sex, data = lung), surv.colour = c("red", "blue"))
Error: Aesthetics must be either length 1 or the same as the data (208): colour

Note that the number of samples in the error message is wrong.

> dim(lung)
[1] 228  10

from ggfortify.

lselzer avatar lselzer commented on August 30, 2024

I will take a look tomorrow. I think the issue is with the way that geom_factory() works. Am I right @sinhrks ? I likely fix would for geom_factory() to check if the column exists in the data if not, check if it is a valid colour.

from ggfortify.

terrytangyuan avatar terrytangyuan commented on August 30, 2024

A pull request for fixing this would be appreciated! @lselzer @DarioS @averissimo

from ggfortify.

Related Issues (20)

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.