I have a data frame df.europeCoords
which looks like this:
And I plot a Europe map with the following code:
## Plot the map: ##
p <- ggplot(data = df.europeCoords, aes(x = longitude, y = latitude, group = country,
fill = meanValues, text = paste("<b>", country, '</b>\n')),
color = "black", size = 0.1) +
geom_polygon(aes(color = border), size = 0.4) +
scale_color_manual(values = c(NA, color = "black", size = 1), guide = FALSE) + #guide = FALSE
coord_map(xlim = c(15, 20), ylim = c(32, 71)) +
theme_classic() +
scale_fill_gradient(name = "Price Mean Values", low = "#F9F7EA" , high = "#006E37",
na.value = "#CCCCCC") + # #DCF1D5 #007d3c
theme(axis.text.x = element_blank(), axis.text.y = element_blank(),
axis.ticks.x = element_blank(), axis.ticks.y = element_blank(),
axis.title = element_blank(),
plot.margin = unit(0 * c(-1.5, -1.5, -1.5, -1.5), "lines")) +
geom_text(data = df.longLat, aes(x = long, y = lat, label = meanValues, fontface = "bold"), size = 3.5)
## Generate ggplot() to plot_ly() object: ##
PowerEuropePlot <- plotly::ggplotly(p, tooltip = "text") %>%
layout(title = paste('<b>POWER Price Information</b>',
'\n<span style="font-size: 14px;">',
"SPOT",'\n</span>'),
margin = list(t = 50),
xaxis = ax, yaxis = ax)
This yield the following plot:
I want to hide the red bordered legend, which already work when I have a look on p
. I hide this legend with the following: scale_color_manual(values = c(NA, color = "black", size = 1), guide = FALSE)
, but when I use plotly::ggplotly(p, ...)
the legend is shown, which is not what I want.
Why is this happening?
structure(list(longitude = c(20.5902474301049, 20.4631750830992,
20.6051819190374, 21.0200403174764, 20.9999898617472, 20.6749967790636,
20.6150004411728, 20.1500159034105, 19.9800004411701, 19.9600016618732
), latitude = c(41.8554041611336, 41.5150890162753, 41.0862263046852,
40.8427269557259, 40.580003973954, 40.434999904943, 40.1100068222594,
39.624997666984, 39.6949933945234, 39.915005805006), country = c("Albania",
"Albania", "Albania", "Albania", "Albania", "Albania", "Albania",
"Albania", "Albania", "Albania"), border = c(FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), meanValues = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_)), row.names = c(NA, 10L), class = "data.frame")