Is it possible to have a horizontal color bar in plotly.js

拜拜、爱过 提交于 2019-12-24 02:47:06

问题


I am working with choropleth charts in plotly.js. Is there a way to get the colorbar scale to display horizontally at the bottom of the chart instead of vertically along the right or left sides?

For reference, check out the first example given at the Plotly site https://plot.ly/javascript/choropleth-maps/#world-choropleth-map-robinson-projection

Thank you!

Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2010_alcohol_consumption_by_country.csv', function(err, rows){
      function unpack(rows, key) {
          return rows.map(function(row) { return row[key]; });
      }

    var data = [{
        type: 'choropleth',
        locationmode: 'country names',
        locations: unpack(rows, 'location'),
        z: unpack(rows, 'alcohol'), 
        text: unpack(rows, 'location'),
         autocolorscale: true
    }];

    var layout = {
      title: 'Pure alcohol consumption among adults (age 15+) in 2010',
      geo: {
          projection: {
              type: 'robinson'
          }
      }
    };
    Plotly.plot(myDiv, data, layout, {showLink: false});
});

回答1:


Unfortunately No. There is already a bug logged about it on Github on Apr 15, 2016

https://github.com/plotly/plotly.js/issues/1244

I don't see any progress on it.



来源:https://stackoverflow.com/questions/43102246/is-it-possible-to-have-a-horizontal-color-bar-in-plotly-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!