javascript - Recale plotly js z axis on zoom -
plotly.js 2d histograms , contour plots automatically generate z-axis range accommodates entire range of z values in dataset being plotted. fine start, when click-and-drag on plot zoom in, i'd z axis range zoom in accommodate range of z values on display; instead, z axis never changes. here's codepen (forked plotly examples, plotly) play around with: http://codepen.io/anon/pen/mkgyjp
(codepen code inline:
var x = []; var y = []; (var = 0; < 500; ++) { x[i] = math.random(); y[i] = math.random() + 1; } var data = [ { x: x, y: y, type: 'histogram2d' } ]; plotly.newplot('mydiv', data); )
this seems pretty conventional behavior - missing option in docs somewhere this?
if there's no built-in option this, acceptable alternative solution manually set new z limits in zoom callback, easy enough implement per example: http://codepen.io/plotly/pen/dogexw - in case question becomes, there convenience method min , max z on display?
thanks in advance,
plotly.js doesn't have zoom-specific callback @ moment(follow issue updates).
one alternative add mode bar button updating colorscale range:
plotly.newplot('mydiv', data, {}, { modebarbuttonstoadd: [{ name: 'click here update colorscale range', click: function(graphdata) { var xrange = graphdata.layout.xaxis.range, yrange = graphdata.layout.yaxis.range; var zmin, zmax; // code compute colorscale range // given xrange , yrange // example given these values: zmin = 10; zmax = 20; plotly.restyle('mydiv', {zmin: zmin, zmax: zmax}); } }] }); complete example: http://codepen.io/etpinard/pen/jgvnjv
Comments
Post a Comment