0

I would like you to point out to me where does the python indentation inconsistency lie here?

Using matplotlib to plot price data, and even all looks good, but getting an error TabError: inconsistent use of tabs and spaces in indentation. File "candles_indexes.py", line 19 candle_ohlc = candlestick_ohlc(self.ax, self.stock_data.values, width = 0.6, colorup = 'green', colordown = 'red', alpha = 0.8)

The error suggestion is pointing out that the mistake lies at the very end of that line.

But here is the code, all looks good to me...

def display_candle_bars(self):
    fig, ax = plt.subplots()

    #Describe candle properties    
    candle_ohlc = candlestick_ohlc(self.ax, self.stock_data.values, width = 0.6, colorup = 'green', colordown = 'red',  alpha = 0.8)

    #allow grid 
    ax.grid(True) 
  
    #Setting labels  
    ax.set_xlabel('Date') 
    ax.set_ylabel('Price')

Any ideas?

noah
  • 2,616
  • 13
  • 27
Teo
  • 97
  • 1
  • 9
  • 6
    I'm guessing you used tabs for `ax.grid` and your `ax.set` lines. Don't mix tabs and spaces – C.Nivs Feb 03 '21 at 16:57
  • 2
    set your editor to use 4 spaces for indentation --> [as shown here](https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation) – Insula Feb 03 '21 at 16:57
  • You have a tab after the `def display_candle_bars(...` line. –  Feb 03 '21 at 17:00
  • The reason why mixing tabs and spaces is now considered an error is precisely *because* it "looks" OK, depending on your editor's tab settings. – chepner Feb 03 '21 at 17:01
  • my editor is set to use 4 spaces for indentation, and to use tab 4 spaces... still getting an error, however it changed a bit. now it says ```def display_candle_bars(self): ^ IndentationError: unindent does not match any outer indentation level``` However thank you all for the valuable advice, I will rewrite the code from the beginning using only spaces and see if that helps. – Teo Feb 03 '21 at 19:18

0 Answers0