Pandas - Plot stacked bar chart

时间:2016-02-12 20:31:42

标签: python pandas matplotlib plot

I have a pandas dataframe representing a table with 2 columns and 4 rows

['url1', 'url2'].forEach(function(imageUrl){

    var img = new Image();
    $(img).attr('src', imageUrl).attr('alt', 'thumbnail' + 1);
    $(img).appendTo($('.thumbnail')).hide().fadeIn(400);
    $('.thumb img').load(function(){
      $('.loader').fadeOut(300);
      $(this).addClass("thumbimage");
    });

});

I need to draw stacked bar (matplotlib) of values and the names should be shown in legend I tried this (with no success):

Name | Value
 n1  | 10.3
 n2  | 5
 n3  | 15
 n4  | 8

How can I do it? I saw this question Pandas - Plotting a stacked Bar Chart. Not sure how to use it in my case

1 个答案:

答案 0 :(得分:3)

If you want to use the names as categories you need to have them in the columns. So first set the index to ... for(auto & scope : Scopes) { auto ret = lookup_helper(key, scope); if(ret) return ret; } ... and then transpose.

'Name'

stacked plot