ropensci / visdat

Preliminary Exploratory Visualisation of Data
https://docs.ropensci.org/visdat/
Other
450 stars 47 forks source link

define my palette appear Error: could not find function "discrete_colours" #120

Closed wanpingDou closed 4 years ago

wanpingDou commented 5 years ago

I try to use define_palette() to defind my ggthemr, but appear Error in discrete_colours(colours) : could not find function "discrete_colours" so,I use ggthemr('flat')/ggthemr('flat')/ggthemr('pale')......ok

njtierney commented 5 years ago

Hello - can you please post a reproducible example of this problem, I'm not familiar with the define_palette function from ggthemr

wanpingDou commented 5 years ago

Hello - can you please post a reproducible example of this problem, I'm not familiar with the define_palette function from ggthemr

now ,is ok! like this:

library(ggthemr)
library(visdat)

tableau10 <- c('#AEC7E8','#FFBB78','#98DF8A',
    '#D62728','#FF9896','#C5B0D5','#C49C94',
    '#5E2C25','#F3C57B','#89F27A'
    )
tableau10 <- define_palette(swatch = tableau10,
    gradient = c(lower = tableau10[1L], 
    upper = tableau10[2L])
    )
ggthemr(tableau10)

dt <- data.frame(a=c(1,2,3,NA,5),b=c('1','2',NA,'4',NA))
vis_dat(dt)
njtierney commented 4 years ago

Hi @wanpingDou ,

Is this what you would expect, from ggthemr?

library(ggthemr)
#> Loading required package: ggplot2
library(visdat)

tableau10 <- c('#AEC7E8','#FFBB78','#98DF8A',
               '#D62728','#FF9896','#C5B0D5','#C49C94',
               '#5E2C25','#F3C57B','#89F27A'
)

tableau10 <- define_palette(swatch = tableau10,
                            gradient = c(lower = tableau10[1L], 
                                         upper = tableau10[2L])
)
ggthemr(tableau10)

dt <- data.frame(a=c(1,2,3,NA,5),b=c('1','2',NA,'4',NA))
vis_dat(dt)
#> Warning: Removed 3 rows containing missing values (geom_raster).

Created on 2020-05-14 by the reprex package (v0.3.0)

wanpingDou commented 4 years ago

Hi @wanpingDou ,

Is this what you would expect, from ggthemr?

library(ggthemr)
#> Loading required package: ggplot2
library(visdat)

tableau10 <- c('#AEC7E8','#FFBB78','#98DF8A',
               '#D62728','#FF9896','#C5B0D5','#C49C94',
               '#5E2C25','#F3C57B','#89F27A'
)

tableau10 <- define_palette(swatch = tableau10,
                            gradient = c(lower = tableau10[1L], 
                                         upper = tableau10[2L])
)
ggthemr(tableau10)

dt <- data.frame(a=c(1,2,3,NA,5),b=c('1','2',NA,'4',NA))
vis_dat(dt)
#> Warning: Removed 3 rows containing missing values (geom_raster).

Created on 2020-05-14 by the reprex package (v0.3.0)

Yes, my problem has been solved with the method above.THX boy.

njtierney commented 4 years ago

OK great!