Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 matplotlib.pyplot issue
#1
I had an issue to run this code:
predicted_stock_price = model.predict(X_test)
predicted_stock_price = sc.inverse_transform(predicted_stock_price)

# Visualising the results
plt.plot(df.loc[800:, ‘Date’],dataset_test.values, color = ‘red’, label = ‘Real Price’)
plt.plot(df.loc[800:, ‘Date’],predicted_stock_price, color = ‘blue’, label = ‘Predicted Price’)
plt.xticks(np.arange(0,459,50))
The error:
Error:
plt.plot(df.loc[800:, ‘Date’],dataset_test.values, color = ‘red’, label = ‘Real Price’) ^ SyntaxError: invalid character in identifier
scidam wrote Jul-22-2020, 11:57 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote
#2
It seems that you are using illegal character...: Use " or ' instead.
Quote
#3
This code works fine for me. I guess you have not used proper quotes
import matplotlib.pyplot as plt
predicted_stock_price = model.predict(X_test)
predicted_stock_price = sc.inverse_transform(predicted_stock_price)
 
# Visualising the results
plt.plot(df.loc[800:, 'Date'],dataset_test.values, color = 'red', label = 'Real Price')
plt.plot(df.loc[800:, 'Date'],predicted_stock_price, color = 'blue', label = 'Predicted Price')
plt.xticks(np.arange(0,459,50))
Here is the code and it run fine on my data and predictions.Although you can use matplotlib do make quite interactive plots.Check them out too
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  matplotlib.pyplot functions create new figures instead of applying to the current one karkas 2 197 Jul-09-2020, 08:32 AM
Last Post: karkas
  Plotting issue Matplotlib garam0 0 321 May-23-2020, 12:11 AM
Last Post: garam0
  zooming in pyplot window SchroedingersLion 0 621 Aug-02-2019, 02:59 PM
Last Post: SchroedingersLion
  How to draw rectangles in pyplot? SuchtyTV 4 2,798 Jul-14-2019, 02:41 PM
Last Post: SuchtyTV
  How to arrange the four pictures of a matplotlib.pyplot? vokoyo 0 833 Apr-04-2019, 10:58 PM
Last Post: vokoyo
  matplotlib pyplot ginput issue MLiljeroth 0 1,302 Oct-12-2018, 07:12 AM
Last Post: MLiljeroth
  Problem with Matplotlib.pyplot LTMP 1 860 Aug-21-2018, 04:50 AM
Last Post: ichabod801

Forum Jump:


Users browsing this thread: 1 Guest(s)