-5

When I plot a pandas Series in ipython notebook and setting the label as suggested by this answer:

plt1=some_series.plot(marker='o', title='Count Distribution')
plt1.set_xlabel='x Count'
plt1.set_ylabel='y Frequecy'

and evaluate the cell. The plot shows with the title, but not the x or y labels. How can I do this in ipython notebook?

And the comment by Chrispy on that post

Is there a particular reason why x and y labels can't be added as arguments to pd.plot()?

might also be a related issue worth answering.

EDIT: Thanks, now I know the error, my fault. But why doesn' t it throw me an error on the value assignment to methods?

Community
  • 1
  • 1
xgdgsc
  • 1,367
  • 13
  • 38

1 Answers1

2

In the post you link, it shows that set_xlabel/set_ylabel are methods, not attributes. Therefore they should be called (using parentheses):

plt1 = some_series.plot(marker='o', title='Count Distribution')
plt1.set_xlabel('x Count')
plt1.set_ylabel('y Frequency')
Community
  • 1
  • 1
wflynny
  • 18,065
  • 5
  • 46
  • 67
  • Thanks. I must be too tired when doing this. Why doesn' t it give me an error message? – xgdgsc Dec 16 '14 at 02:23
  • By default, `plt1.set_xlabel` points to a function (`Axes.set_xlabel()` which calls something like `Axes.xaxis.set_label_text()`). You simply overwrote that and set `plt1.set_xlabel` to point to the string `'x Count'`. – wflynny Dec 16 '14 at 16:06