Skip to content
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

intentional duplicated catergorical items disappear when plotting #1678

Closed
jblamyatifremer opened this issue Jan 3, 2020 · 1 comment
Closed

Comments

@jblamyatifremer
Copy link

jblamyatifremer commented Jan 3, 2020

Dear plot_ly creators,

I am using R and I am trying to plot a heatmaps with duplicates items (in x and y axis) to ease the visualization. The items are categorical. I also read all issues regarding the categorical axis : #189 #242, #399, #379. But here the problem is different.

I create a simple code to reproduce the problem :

## create fake dataset
m <- matrix(rnorm(9), nrow = 3, ncol = 3)
x <- c("a", "a", "c")
y <- c("d", "e", "e")

## plot it
t <- plot_ly(
    x = x, y = y,
    z = m, type = "heatmap"
)
t

I expected to get a 3 X 3 heatmaps, but I only get a 2 X 2 heatmaps. I also tried my elaborate code :

## use the same dataset as above
ax <- list(
    type = "category",
    categoryarray = x,
    categoryorder = "array",
    showgrid = TRUE,
    showline = TRUE,
    autorange = TRUE,
    showticklabels = TRUE,
    ticks = "outside",
    tickangle = 45,
    tickfont=30
)

ay  <- list(
    type = "category",
    categoryarray = y,
    categoryorder = "array",
    showgrid = TRUE,
    showline = TRUE,
    autorange = TRUE,
    showticklabels = TRUE,
    ticks = "outside",
    tickangle = 0,
    tickfont=30
    
)

t <- plot_ly(
    x = x, y = y ,
    z = m, type = "heatmap"
)  %>%
    layout( margin = list(l = 150, r = 50, b = 150, t = 0, pad = 4), title = 'relatedness R',
            xaxis = ax, yaxis = ay)
t

I got exactly the same results. Any idea to solve/trick this will be welcome.

session INFO : R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
plotly_4.9.1

Cheers,
JB

@jblamyatifremer
Copy link
Author

Dear all,
Solution found. It is rename the duplicated item !

## create fake dataset
m <- matrix(rnorm(9), nrow = 3, ncol = 3)
x <- c("a", "aa", "c")
y <- c("d", "e", "ee")

## plot it
t <- plot_ly(
    x = x, y = y,
    z = m, type = "heatmap"
)
t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant