0

I'm trying to plot a set of data from a csv that I specified using .loc, however, upon running it, the graph shows, but the lines don't. The selected has a range of 0 to approx 1.4k, however, the y and x axes aren't showing the full length, and the date is being shown as decimals. Here is the code, hopefully that could help explain better.

ranges = eth.loc['2015-07-30':'2020-08-14', 'Value']
## Plotting Ranges
plt.figure(figsize=(10, 6))
ranges.plot(kind='line')
plt.title('Price of ETH')
plt.xlabel('Date')
plt.ylabel('Price')
plt.show()

Also, here is the output that I'm getting. Plot Thanks!

N T
  • 43
  • 1
  • 6
  • It's not really possible to answer this definitively without some data. Please include the top rows of `eth`. See [How to provide a reproducible copy of your DataFrame using `df.head(30).to_clipboard()`](https://stackoverflow.com/questions/52413246), then **[edit] your question**, and paste the clipboard into a code block. – Trenton McKinney Aug 16 '20 at 04:50
  • In order to do `ranges = eth.loc['2015-07-30':'2020-08-14', 'Value']`, the index of `eth` must be a `datetime` index. – Trenton McKinney Aug 16 '20 at 05:04

1 Answers1

0

You never put your data (ranges) in the chart (plt). There has to be a

plt.plot(ranges...)

in your code.

Robert Altena
  • 787
  • 2
  • 11
  • 26
  • I tried that however it still didn't work, I'm doing this instead: ```df.loc['7/30/2016':'8/30/2016', 'Price'].plot(xlabel='Date', ylabel='Price', title='ETH Price')``` The issue is that regardless of the dates specified, it always prints 100 days, and they are always the last 100 days. – N T Aug 16 '20 at 03:21
  • The issue regarding the lines displaying was fixed by that, however I'd still like to know how to get it to render the specified dates, along with actually displaying them as dates instead of just numbers. – N T Aug 16 '20 at 03:25
  • Just use mplginance: https://github.com/matplotlib/mplfinance – Robert Altena Aug 16 '20 at 04:15
  • _You never put your data (ranges) in the chart (plt). There has to be a `plt.plot(ranges...)`_ is not correct. The plot is set with `ranges.plot(kind='line')`, which should plot the selection just fine because `ranges` is a dataframe and [pandas.DataFrame.plot](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html) – Trenton McKinney Aug 16 '20 at 04:54
  • @TrentonMcKinney Yes, I thought so too. However upon rendering the plot, nothing shows up, only the image that I sent. Could this be an issue on my end? – N T Aug 16 '20 at 09:46
  • You could try only the Dataframe.plot: ranges.plot(kind='line') @TrentonMcKinney has a point. That line by itself should just give you a basic plot. – Robert Altena Aug 16 '20 at 11:12