Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
I have a script which when entered into Microsoft R Open version GUI I get one chart displayed which is correct. However, when using precisely the same code within Power BI, the segments of the pie chart do not colorate with those from the R GUI?
The code is pasted below:
library(ggplot2)
library(scales)
blank_theme <- theme_minimal() +
theme(
plot.title = element_text(size=16, face="bold"),
axis.title = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.ticks = element_blank(),
axis.text.y = element_blank(),
axis.text.x = element_text(color='black'),
panel.grid = element_blank()
)
df <- data.frame(
value = c(6019, 2211, 314),
Legend = c("Registered Within", "Registered On", "Registered Out")
)
p <- ggplot(df, aes(x=1, y=value, fill=Legend))+
ggtitle("Registered DETs 4am") +
coord_polar(theta='y')
y.breaks <- cumsum(df$value) - df$value / 2
p <- p +
scale_fill_manual(values=c("#FD625E", "#F2C80F", "#01B8AA"))+
geom_bar(stat="identity", color="black") +
guides(fill=guide_legend(override.aes=list(colour=NA))) +
blank_theme +
theme(axis.text.x=element_blank()) +
scale_y_continuous(
breaks = y.breaks,
labels=df$Legend
) +
geom_text(
aes(
y = value / 3 + c(0, cumsum(value)[-length(value)]),
label = format(value/sum(value)*100, digits=2, nsmall=2)
),
size=4
) +
labs(
title="Registered DETs - 04:00"
)
p
Everything is contained within the code above, for this to be tested.
In the R GUI, the order is "Registered In", "Registered On", "Registered Out" along with the correct data, however, in Power BI, the labels are ordered correctly, but the segments are drawn in the order of "Registered In", "Registered Out", "Registered On".
Does anyone know why this is the case?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.