Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stacked bar chart changes x axis plot number values

Question:

If I choose the plot option stacked = False I get the correct x axis output for my data.

false stacked

However, when I use stacked = True I get incorrect output showing higher (incorrect) values on the x axis. Nothing else has changed apart from the stacked option.

enter image description here

Am I missing something obvious here?

Data

DataFrame.to_dict() output here

import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

cols = ['OpenToLast','OpenToMaxHigh','OpenToMaxLow']
colors = {'OpenToLast':'b', 'OpenToMaxHigh' : '#CCD1F5', 'OpenToMaxLow': '#C6DAF4'}


axnum = auction[cols].plot(kind='barh',
                        figsize=(6,8),   
                        fontsize=9,
                        color=[colors[i] for i in cols],
                        edgecolor = "none",   
                        stacked = False,  
                        legend = True)

axnum.xaxis.set_major_locator(ticker.MultipleLocator(5))
plt.axvline(0, color='B')
like image 616
nipy Avatar asked Mar 10 '26 08:03

nipy


1 Answers

Stacked plot stacks the individual bars on top of each other rather than overlapping the data. For eg, your top value at 2016-12-16 is 25(open to last), 30(open to max high) which in stacked plot is 25 and 30 stacked together at 55

like image 163
Vaishali Avatar answered Mar 11 '26 22:03

Vaishali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!