Hi,
I am using Python 3.6.5.
When I use the following code to create a Line plot with 2 columns for a data-frame:
...ValueError: view limit minimum -36835.2125 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units...
Here, the type of [Ship Date] is datetime64[ns].
It looks like this error is caused by ax = plt.gca() because after I remove it (and related ax=ax), the code can run smoothly but output 2 line plots.
How to solve this problem if I want to make a Line plot with multiple columns?
I am using Python 3.6.5.
When I use the following code to create a Line plot with 2 columns for a data-frame:
import pandas as pd import xlrd xlsx_source = 'https://community.tableau.com/servlet/JiveServlet/downloadBody/1236-102-2-15278/Sample%20-%20Superstore.xls' df = pd.read_excel(xlsx_source, sheet_name='Orders') df.head() import matplotlib.pyplot as plt ax = plt.gca() df.plot(kind='line', x='Ship Date', y='Profit', color='red', ax=ax) df.plot(kind='line', x='Ship Date', y='Sales', color='blue', ax=ax) plt.show()However, get an error:
...ValueError: view limit minimum -36835.2125 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units...
Here, the type of [Ship Date] is datetime64[ns].
It looks like this error is caused by ax = plt.gca() because after I remove it (and related ax=ax), the code can run smoothly but output 2 line plots.
How to solve this problem if I want to make a Line plot with multiple columns?