I have built the following composite plot:
# 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)
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
bubblecolor = cgrad(:inferno, rev = true, scale = :exp)
then I get:
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