Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dadorno
Regular Visitor

Dynamic Coloring with R Scripting

Hello!  

 

I have a side-passion project I'm working on.  Including a very basic DUMMY data set below.  What I am trying to create is a box and whisker plot through R, for each individual ID.  I can actually do this part, but what I also need is for the individual points to appear by company, and for a single company to be a different color, depending on user choice.  

 

For example, if the first sheet of the dashboard had a slicer where the end user chose their company (with this data, lets say they chose Z, from their choices of X, Y and Z).  When they go to the next tab, when looking at the box/whisker plot for ID a, they would see 3 points with the graph (X,Y,Z), and the point for Z would be colored RED and the others would be GREY (or something to this effect).  

 

I can create the R-boxplot visuals, but cannot get the dynamic color changing.  Any suggestions?  I'm not sure if I need measures, or columns, or what might be best. Thank you all for your help in advance.  

 

Company ID PRICE
Z a 100
Z b 99
Z c 98
Z d 98
Y a 99
Y b 99
X a 100
X c 101
X d 98

2 REPLIES 2
Icey
Community Support
Community Support

Hi @dadorno ,

 
Is this problem sloved?
 
If it is sloved, could you kindly accept it as a solution to close this case?  
 
If not, please let me know.  
 
Best Regards
Icey
Icey
Community Support
Community Support

Hi @dadorno ,

I am currently unable to fulfill your request. Maybe you can try this.

The code in R Script Editor is below:

data<-dataset
library(ggplot2)
ggplot(data,aes(ID,PRICE))+geom_boxplot()+geom_boxplot(aes(colour = ID))+facet_grid(~Company)

Dynamic Coloring with R Scripting5.PNGDynamic Coloring with R Scripting6.PNG

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.