You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to replicate my colleagues chart in Rpubs using ploty which includes hover labels and a legend. RPubs - HTML
I am a new user to R, so have installed the ploty package within the last month, which means I am using the latest version. When I replicate the code exactly, my chart once using ploty removes the legend, therefore I am unable to select economic activity. RPubs - Economic activity by age
Below is the code to produce the chart which does include the legend, it is only when the plotly line is run that the legend is removed.
Thanks in advance
p1 ← ggplot(df1, aes(y=percent, x=AAGE,
text = paste('Economic activity: ',INECAC05_2 ,‘% of total:’, percent(percent, accuracy = 0.01),‘Age:’, AAGE ))) +
geom_col(aes(fill=forcats::fct_rev(INECAC05_2)), width = 0.7)+
geom_text(data=subset(df1,percent > 0.01),
aes(y = lab_ypos, label= paste0(round(percent*100, 1), “%”), group =INECAC05_2), color = “Black”, size = 3)+
scale_y_continuous(labels = scales::percent)+
theme_minimal() +
theme(legend.position=“right”) +
guides(fill = guide_legend(reverse = FALSE) +
labs(x =“Age groups”,
y = “% of everyone in age group”,
fill = “Economic activity”,
title = “Economic activity by age”, #subtitles are a smaller font than title.
caption = “Analysis of APS Jul 2020 - Jun 2021 \nWe have combined the categories ‘unpaid family worker’ and
‘Government training scheme’ with ‘Employee’. Labels <1% have been suppressed.”) +
scale_fill_manual(values=c(“#999999”, “#E69F00”, “#56B4E9”, “#009E73”, “#F0E442”, “#0072B2”, “#D55E00”, “#CC79A7”))
ggplotly(p1, tooltip = “text”)
The text was updated successfully, but these errors were encountered:
Unfortunately your issue is not reproducible as you provided no data. However, a similar issue was reported on Stackoverflow. Playing a bit around the issue seems to arise when using guides(), whereas using the guide argument of the scale works.
A minimal reproducible example of the issue using mtcars:
Hi all,
I would like to replicate my colleagues chart in Rpubs using ploty which includes hover labels and a legend. RPubs - HTML
I am a new user to R, so have installed the ploty package within the last month, which means I am using the latest version. When I replicate the code exactly, my chart once using ploty removes the legend, therefore I am unable to select economic activity. RPubs - Economic activity by age
Below is the code to produce the chart which does include the legend, it is only when the plotly line is run that the legend is removed.
Thanks in advance
The text was updated successfully, but these errors were encountered: