Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Matplotlib help!!!
#1
import pandas as pd
from pandas import Series
from matplotlib import pyplot as plt


data = pd.read_csv ('data.csv')

plt.plot(data.Date, data.Leverage)
plt.show()
Data
Date Leverage
Dec-52 2.01%
Mar-53 1.64%
Jun-53 0.51%
Sep-53 0.29%
Dec-53 0.72%
Mar-54 1.99%
Jun-54 4.59%
Sep-54 5.50%
Dec-54 5.90%
.......
Sep-15 -1.24%
Dec-15 -1.29%
Mar-16 -0.25%
Jun-16 0.90%
Sep-16 1.76%
Dec-16 1.42%
Mar-17 0.75%
Jun-17 -0.04%
Sep-17 -0.52%
Dec-17 -0.11%
Mar-18 -0.48%
Jun-18 -1.11%
Sep-18 -1.72%


When I plot this data using matplotlib, the data look very different (image attached). The Y axis is not clear and the data does not supposed to look like the one shown in the picture. Can someone point out where I am going wrong?

Thanks

Attached Files

Thumbnail(s)
   
Reply
#2
It's probably reading in all of your data as strings. You will need to convert that data to dates and percentages for it to plot correctly.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,161 Mar-11-2021, 10:52 AM
Last Post: buran

Forum Jump:

User Panel Messages

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