vcs icon indicating copy to clipboard operation
vcs copied to clipboard

VCS Legend issues

Open chaosphere2112 opened this issue 8 years ago • 4 comments

Looks like there are a couple of issues with the legend (at least when using boxfill).

This notebook illustrates most of the issues I found, but I'll break it down individually as well.

boxfill.legend label placement is wrong

When you assign values to it, it should use that dictionary to draw tickmarks on the legend at the appropriate point for the values used as the keys; this should work fine:

import vcs
box_data = [range(0, 100, 20) for _ in range(5)]
boxfill = vcs.createboxfill()
boxfill.boxfill_type = "custom"
boxfill.levels = [0, 10, 30]
boxfill.legend = {1: "one", 16: "sixteen", 25: "twentyfive"}
x = vcs.init()
x.plot(box_data, boxfill)

legend_placement

Legend will draw as many sections as it can

When you have more fillarea* items than levels, weird stuff starts to happen with the legend (though the data looks fine).

import vcs, cdms2
x = vcs.init()
f = cdms2.open(vcs.sample_data + '/clt.nc')
s = f('clt')
box = vcs.createboxfill()
box.boxfill_type = "custom"
box.fillareacolors = [1, 2, 3, 4]
box.fillareaindices = [2, 3, 4, 5]
box.fillareastyle = "hatch"
box.levels = [0, 50, 100]
x.plot(s, box)

wat

At some point I was also able to make legend sections draw over themselves, but I haven't been able to reproduce that one yet.

chaosphere2112 avatar Oct 12 '16 20:10 chaosphere2112