Python Forum
matplotlib.pyplot issue
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
Reply
#2
It seems that you are using illegal character...: Use " or ' instead.
Reply
#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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  matplotlib.pyplot functions create new figures instead of applying to the current one karkas 2 2,090 Jul-09-2020, 08:32 AM
Last Post: karkas
  Plotting issue Matplotlib garam0 0 1,525 May-23-2020, 12:11 AM
Last Post: garam0
  How does pyplot know what was plotted by the output of pandas.DataFrame(...).cumprod( codeowl 2 2,192 Mar-28-2020, 08:27 AM
Last Post: j.crater
  zooming in pyplot window SchroedingersLion 0 2,193 Aug-02-2019, 02:59 PM
Last Post: SchroedingersLion
  How to draw rectangles in pyplot? SuchtyTV 4 6,425 Jul-14-2019, 02:41 PM
Last Post: SuchtyTV
  How to arrange the four pictures of a matplotlib.pyplot? vokoyo 0 2,769 Apr-04-2019, 10:58 PM
Last Post: vokoyo
  matplotlib pyplot ginput issue MLiljeroth 0 3,541 Oct-12-2018, 07:12 AM
Last Post: MLiljeroth
  Problem with Matplotlib.pyplot LTMP 1 2,840 Aug-21-2018, 04:50 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020