6

Is there a way to set the marker style in pandas.DataFrame.plot? All other options are available by setting the kind. I would like a marker with error bar but just get a line with an error bar. If I was to do this through the function errorbar I would set fmt='.'

1
  • 2
    Sorry I posted an answer and then deleted it but was df.plot(style='.') what you were after? Commented May 6, 2015 at 9:05

2 Answers 2

7

The OP does not specify it, but it depends whether you're trying to plot the Dataframe, or a series.

Plotting DataFrame

Reusing the example by @unutbu:

from numpy import arange, random
import pandas as pd
df = pd.DataFrame({'x': arange(10), 'y': random.randn(10), 'err': random.randn(10)})
df.plot('x', 'y', yerr='err', fmt='.')

Plotting Series in DataFrame

This time it's a bit different:

df.y.plot(fmt='.')
AttributeError: Unknown property fmt

you need:

df.y.plot(style='.')

Plot of series

DataFrame behavior with style

If you pass style to DataFrame.plot, "nothing happens":

df.plot('x', 'y', yerr='err', style='.')

Dataframe plot with default fmt

which may be not what you want.

Sign up to request clarification or add additional context in comments.

Comments

4

df.plot passes extra keyword parameters along to the underlying matplotlib plotting function. Thus,

df = pd.DataFrame({'x':np.arange(10), 'y':np.random.randn(10), 
                   'err':np.random.randn(10)})
df.plot('x', 'y', yerr='err', fmt='.')

yields

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.