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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Architect
Frequent Visitor

Disable R Script Scatterplot Color Change On Filtered/Focused Condition

I have a simple scatterplot setup with (x,y) values by a given "type" as created below in R Script:

 

ggplot(dataset,aes(x = xVal, y = yVal)) + geom_point(aes(color = type)

 

 

 

Everything runs just fine, however, the issue I am facing is while the plot dynamically changes to any slicers or selections, the color of the dots change from what they were originally assigned. For example, if the original legend had:

  • Type 1 = Red
  • Type 2 = Blue
  • Type 3 = Green

    When I interact with my data whether through a table or slicer, focusing on a certain type, for example say applying a slicer to view Type 2, the R Script plot filters correctly but shows the dots as Red when unfiltered they were originally assigned Blue in the legend. Does anyone know how to disable this and have the points "hold" their original assigned color?

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Architect 

Could you show me an example to test and reproduce your problem?

 

Best Regards

Maggie

I believe I gave my line of code already. In any case this is not tied to any particular data case, in my experience it has been its general behavior.

 

Use this simple case:

For a data set:

TYPEXY
A11
B22
C33

 

Add a Table on Power Bi and add the fields to a R Visual.

library(ggplot2)
ggplot(dataset,aes(x = X, y = Y)) + geom_point(aes(color = TYPE))

The R Visual will assign colors for each "TYPE". However when you say click on a row on the table for TYPE B, it will show the dot for B on the R Visual as a different color from what it was originally assigned.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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