# Colorbar doesn't reflect ColorGradient scale as specified in cgrad(..., scale = )

**URL:** https://discourse.julialang.org/t/colorbar-doesnt-reflect-colorgradient-scale-as-specified-in-cgrad-scale/56431
**Category:** General Usage
**Tags:** colors, plots
**Created:** [March 3, 2021, 6:23pm UTC](https://discourse.julialang.org/t/colorbar-doesnt-reflect-colorgradient-scale-as-specified-in-cgrad-scale/56431 "2021-03-03T18:23:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ivan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ivan/32/208442_2.png) [@Ivan](https://discourse.julialang.org/u/Ivan)
#### Post date: [March 3, 2021, 6:23pm UTC](https://discourse.julialang.org/t/colorbar-doesnt-reflect-colorgradient-scale-as-specified-in-cgrad-scale/56431/1 "2021-03-03T18:23:21Z")

</div>

I have built the following composite plot:

```julia
# Data
x = rand([1, 2, 3, 4, 5], 50)
y = rand(50)
z = rand(50)

# Vector with labels to show on hover
hovector = []
for i in 1:length(x)
    label = "$(x[i]), $(y[i]), $(z[i])"
    push!(hovector, label)
 end

# Histograms and blank plot for top right corner
plotly()
x_hist = Plots.plot(x,
    st = :histogram,
    nb = 50,
    leg = false,
    yguide = "Frequency",
    xticks = false,
    guide_position = :left,
    color = RGB{Float64}(0.031,0.318,0.612))
y_hist = Plots.plot(y,
    st = :histogram,
    nb = 50,
    leg = false,
    color = RGB{Float64}(0.031,0.318,0.612),
    yticks = false,
    xguide = "Frequency",
    orientation = :h)
blank = Plots.plot(grid = false, showaxis = false)

# Main plot
bubblecolor = cgrad(:inferno, scale = :exp)
bubbles = Plots.plot(x, y, st = :scatter,     
    marker_z = z,
    ms = 10,
    hover = hovector,
    color = bubblecolor, 
    label = nothing,
    cb = false)

# Workaround for title (plot_title not currently implemented, see http://docs.juliaplots.org/latest/generated/attributes_plot/)
title = Plots.plot(ones(3), line = nothing, size = (600, 80),
    grid = false, showaxis = false, leg = false,
    annotations=(2, 1.5, "Main Title"))

# Merge plots
l = @layout [x_hist blank
            bubbles{0.8w,0.8h} y_hist]
plots = Plots.plot(x_hist, blank, bubbles, y_hist, 
        layout = l, link = :both,
        size = (700, 500))
superplot = Plots.plot(title, plots, layout = grid(2,1,heights=[0.1,0.9]))

# Add colorbar
Plots.plot!([0], [0], zcolor=[NaN], cbtitle="Intensity", leg = false,
        clims = extrema(z),
        color = bubblecolor,
        background_color_subplot=:transparent,
        markerstrokecolor=:transparent, framestyle=:none, 
        cb = :right,
        inset=bbox(0.1, 0, 0.05, 0.9, :center, :right), 
        subplot=6)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/0/3084c3cd0b1d8ab45b1001cf16ae8afe09ea717f.png)

My question is related to the last block `# Add colorbar` (note the color gradient `bubblecolor` defined just under `# Main plot`). I am using an exponential scale for my color gradient to make lower _Intensity_ values stand out more clearly, and although this is reflected in the color of the bubbles themselves, the colorbar still shows the default linear scale of the `:inferno` color gradient. This obviously affects the readability of the main scatter.

If I change the line where bubblecolor is defined to

```julia
bubblecolor = cgrad(:inferno, rev = true, scale = :exp)

```

then I get:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/0/80177cae6bf7eb2325f34365a94015ffec0aac61.png)

So, the `color` attribute in the last block is sensitive to changes in `rev` within `cgrad`, but not `scale`. Is this an expected limitation, or am I doing something wrong?

PS: Any idea why the `cbtitle` “Intensity” doesn’t show up? This is less of an issue but would be great to be able to include it
