Python Forum
Python Matplotlib help!!! - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python Matplotlib help!!! (/thread-15951.html)



Python Matplotlib help!!! - kapilan15 - Feb-07-2019

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


RE: Python Matplotlib help!!! - ichabod801 - Feb-07-2019

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.