Plots.jl: [FR] `legend = false` should not hide colorbar

Created on 4 Jun 2020  Â·  9Comments  Â·  Source: JuliaPlots/Plots.jl

Right now legend = false will also hide the colorbar, leading to the awkward legend = false, colorbar = true. I don't think we ever want the current behaviour. legend and colorbar should simply be separate IMHO

All 9 comments

At this point it has the default value colobar = :legend that copies the behavior of the legend. As per https://github.com/JuliaPlots/Plots.jl/blob/fff8f84acf62550f068810970e146e085264c9c5/src/arg_desc.jl#L107

I guess we should set the default value to be colorbar = :right should it be the case though?

Personally, I think the current behavior is very much reasonable, I wonder what others think

The colorbar already has sensible defaults - it's being shown if you ask for it explicitly, if you have a heatmap or a surface, or if you have color encoding in a variable with line_z or marker_z. I don't see why legend should override those sensible defaults, to be honest.

Consider this case:

plot(rand(4,5), line_z = (1:5)')

Skærmbillede 2020-06-04 kl  09 08 44

plot(rand(4,5), line_z = (1:5)', legend = false)

Skærmbillede 2020-06-04 kl  09 08 54

BTW I think maybe

┌ Warning: Multiple series with different color share a colorbar. Colorbar may not reflect all series correctly.
â”” @ Plots ~/.julia/packages/Plots/JKY3H/src/backends/gr.jl:491

should have been an @info not a warning?

Good point, this is a very good example.

Additionally, would we want no legend if colorbar needs to be drawn?
That is, the default behaviour should be no legend in the presence of colorbar?

Additionally, would we want no legend if colorbar needs to be drawn?
That is, the default behaviour should be no legend in the presence of colorbar?

No, I don't think so. For heatmaps and contours legends are already suppressed automatically and for other cases (see Michael's first plot) it could make sense to have a legend. In that case I would leave removing the legend to the users.

Agree with Daniel. The issue is also there with composite plots
amphibians
(e.g. if I want to combine a heatmap with a polygon such as in the below example), but that should also be solved by unlinking them.

Nice plot! What does it show?

Species richness of the world's 6000 species of amphibians :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asinghvi17 picture asinghvi17  Â·  3Comments

kersulis picture kersulis  Â·  5Comments

cortner picture cortner  Â·  4Comments

crstnbr picture crstnbr  Â·  3Comments

Cody-G picture Cody-G  Â·  4Comments