cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
When creating dashboards, we often would like to ensure that the same colors correspond to the same series across multiple charts. This could be desirable because our series could have associated brand colors, or simply to ensure continuity and effective use of color. ("The red bar on one chart is the same series as the red bar in my other chart.")

While we can definitely use Sisense for Cloud Data Teams' visualization option to assign colors strategically, we can leverage SQL Views and ggplot2's scale_fill_manual function to more easily apply the same color scheme consistently.

Step 1: Create a view that assigns your series to R colors.  R has many exciting options to choose from - a list of supported colors can be found here!

Here's the query for a view, called source_color_key, for different sources in a fictional gaming company.
select 'admob' as source,'magenta' as color
union all
select 'leadbolt' as source, 'navy' as color
union all
select 'organic' as source, 'olivedrab' as color
union all
select 'tapjoy' as source, 'darkgoldenrod' as color
Step 2: Join your SQL output to your color key view

Step 3: Use ggplot's scale_fill_manual parameter, as shown below, to assign your custom values to your series. Remember to create a named vector that contains the name, color of each series value.
library(ggplot2)

cols=df$color
names(cols)=df$source

a=ggplot(df,aes(x=source,y=count,fill=source)) + geom_bar(stat="identity") + scale_fill_manual(values=cols)

periscope.image(a)
The final result looks like this!
Note that if we are even missing a series entirely, we still preserve the assigned coloring. In the graph below, we don't have any data for the "organic" source, but none of the other colors have changed due to our named vector.
Any other tips and tricks you like to use for coloring your graphs?
Version history
Last update:
‎03-02-2023 09:29 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: