Pandas chart with error: style not applied

I have a Pandas object (version 0.14.1) DataFrame similar to this

 import pandas as pd df = pd.DataFrame(zip([1, 2, 3, 4, 5], [0.1, 0.3, 0.1, 0.2, 0.4]), columns=['y', 'dy']) 

returns

  y dy 0 1 0.1 1 2 0.3 2 3 0.1 3 4 0.2 4 5 0.4 

where the first column is the value and the second is the error.

First case : I want to make a plot for y -values

 df['y'].plot(style="ro-") 

First case

Second case : I want to add dy vertical error bars for y -values

 df['y'].plot(style="ro-", yerr=df['dy']) 

Second case

So, if I add the yerr or xerr to the plot method, it ignores style .

Is it a Pandas feature or bug?

+7
source share
1 answer

As TomAugspurger noted, this is a known issue . However, in most cases this simplifies the workaround: use the fmt keyword instead of the style keyword to specify shortcut style options.

 import pandas as pd df = pd.DataFrame(zip([1, 2, 3, 4, 5], [0.1, 0.3, 0.1, 0.2, 0.4]), columns=['y', 'dy']) df['y'].plot(fmt='ro-', yerr=df['dy'], grid='on') 

correctly formed figure

+2
source

Source: https://habr.com/ru/post/974935/


All Articles