0

Two follow-up questions to a post from yesterday (Multiple Y Axes), is it possible to:

  1. Set the scale increments with ylim or yticks? (so that they line up at 5 steps each)
  2. Change the right Y-axis data to kind='bar' ?

The gridlines do not match up (see image):

enter image description here

Edit: I did not understand that I was plotting in 2D lines by default, so I was trying to change the "kind" as I would in pandas; for example, df.plot(kind='').

Community
  • 1
  • 1
MJS
  • 1,573
  • 3
  • 17
  • 26
  • Not sure what you mean by *"Change the right Y-axis data to `kind='bar'`"*. Are you asking [how to draw a bar chart](http://matplotlib.org/examples/api/barchart_demo.html)? – ali_m Dec 01 '15 at 22:24
  • No. The error message is that line has no property "kind". – MJS Dec 02 '15 at 01:57
  • You will have to explain more clearly what you're trying to do. It's not clear what *"line"* refers to in your comment, but it sounds like you are assuming you can convert an existing `matplotlib.lines.Line2D` object into a bar graph, which is just not possible. As the error message tells you, `matplotlib.lines.Line2D` objects have no `.kind` attribute. – ali_m Dec 02 '15 at 19:37
  • Hi ali_m - sorry for the delay in coming back. In trying to integrate code that I found on SO, I did not understand that my ax1.plot() and ax2.plot() statements were different than a pandas dataframe df.plot() statement... in which it's possible to set kind='bar'. That's just a lack of experience/understanding on my part. I found this language in the dataframe.plot() documentation: " New in version 0.17.0: Each plot kind has a corresponding method on the DataFrame.plot accessor: df.plot(kind='line') is equivalent to df.plot.line()." – MJS Dec 03 '15 at 16:24
  • I see. Pandas basically provides convenience wrappers around some of matplotlib's plotting functionality, but these methods are necessarily more limited than using matplotlib directly. It sounds as though you may have already figured out the problem by yourself, in which case it would be great if you could edit your question so that it is specifically about the error message you were seeing (`TypeError: There is no Line2D property "kind"`), then post an answer explaining what the cause is. – ali_m Dec 03 '15 at 17:11
  • If not, could you please edit your question to explain more clearly what you want help with. – ali_m Dec 03 '15 at 17:13

0 Answers0