1

I would like to plot values onto the X and Y axis'. I do not want to put any data in the graph, just label the Axis' with Time and DID(As seen below)

Here is my code:

import pandas as pd 
import matplotlib.pyplot as plt
from matplotlib import style 
style.use('ggplot')


df = pd.read_csv('Test_Sheet_1.csv')

Time = df.ix[8:, 1]

DID = df.ix[1, 6:13]


ax1 = plt.subplot2grid((6,6), (0,0), rowspan=1, colspan=6)

ax1.plot(Time)

plt.show() 

and i receive this error:

Could not convert string to float.

yes what i am trying to put on the x, and y axis are letters, not numbers, so this error is valid. how do i fix this problem? Is there any easy way to plot these DID's and Times from the graph without getting this error?

Also, i am new to python, and coding in general, so if my question isnt clear please let me know, and i will try my best to fix it.

Thank you very much!

2
  • I think this is actually a matplotlib issue rather than a pandas one. Commented May 5, 2017 at 13:40
  • My guess is that you shouldn't plot Time but instead some dummy data and then make it invisible with alpha=0; then set the axis with ax.set_xlabel etc. Commented May 5, 2017 at 15:39

1 Answer 1

1

The Time column may not be of type DateTime.

Will this work with an explicit conversion?

ax1.plot(pd.to_datetime(Time))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.