#Hi Everyone,
I’m having an issue with the published ggplot2 graphs not appearing correctly relative to the way they appear in R. I’ve got a geom_tile plot that looks like this:
The uploaded Plotly graph loses all the alpha information from the plot and the legend.
I get an error on converting it using ggplotly() that makes me think it’s only looking for atomic values and not vectors for the alpha channel. Is this the case? Is there any way to remedy this? It seems to currently be only taking the first value The error is…
ppp <- ggplotly(pp, tooltip = c(“y”, “x”, “alpha”, “fill”)) %>%
- layout(autosize = F, width = 1000, height = 700, font = f, margin = m, xaxis=x, yaxis=y, title = “Plasmid Presence: Confidence, Incompatability Group”)
Warning messages:
Warning messages:
1: In sub("\)", paste0(",", alpha, “)”), x) :
argument ‘replacement’ has length > 1 and only the first element will be used
2: In sub("\)", paste0(",", alpha, “)”), x) :
argument ‘replacement’ has length > 1 and only the first element will be used
3: In sub("\)", paste0(",", alpha, “)”), x) :
argument ‘replacement’ has length > 1 and only the first element will be used
4: In sub("\)", paste0(",", alpha, “)”), x) :
argument ‘replacement’ has length > 1 and only the first element will be used
My code is…
#Create ggplot
pp <- ggplot(reportable.conf, aes(Plasmid, Sample, alpha = Confidence, fill = Inc_group, text = paste("AMR Gene: ", reportable$AMR_gene))) +
geom_tile(colour = “white”) +
scale_fill_manual(values = colours.inc, name = “Incompatibility Group”) +
theme_classic(base_size = 8) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.45, size = rel(0.8)),
axis.text.y = element_text(size = rel(0.8)),
axis.title.x=element_blank(),
legend.title = element_text(),
axis.title.y=element_blank(),
panel.background = element_rect(fill=“grey95”)) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0))
#Some stylish variables
m = list(
l = 150,
r = 100,
b = 200,
t = 100,
pad = 0
)
f <- list(
family = “Arial, Helvetica, sans-serif”,
size = 8,
color = “#7f7f7f”
)
x <- list(
title = “Plasmid”,
titlefont = f
)
y <- list(
title = “Sample”,
titlefont = f
)
#Convert to Plotly
ppp <- ggplotly(pp, tooltip = c(“y”, “x”, “alpha”, “fill”)) %>%
layout(autosize = F, width = 1000, height = 700, font = f, margin = m, xaxis=x, yaxis=y, title = “Plasmid Presence: Confidence, Incompatability Group”)
plotly_POST(ppp, filename = “r-docs/PP-test”)
The plotly graph itself
https://plot.ly/~adrian.zetner/11/plasmid-presence-confidence-incompatability-group/
Any ideas?