1

I want to produce scatter plots of data from a pandas df, sample below. enter image description here I can produce line plots with:

ax = df_stats.plot(x = 't', y = 't_TI_var_ws')
ax1 = ax.twinx()
df_stats.plot(x='t',y='t_TI_var_pwr',ax=ax1, color='g')

enter image description here

but when I try to use .scatter to plot the same data as a scatter plot I get the error KeyError: 't'

ax = df_stats.plot.scatter(x = 't', y = 't_TI_var_ws')
ax1 = ax.twinx()
df_stats.plot.scatter(x='t',y='t_TI_var_pwr',ax=ax1, color='g')
4
  • 2
    what happens if you do: df_stats.plot(x='t',y='t_TI_var_pwr',ax=ax1, color='g', kind='scatter') Commented Jan 21, 2020 at 17:21
  • the same error KeyError: 't' Commented Jan 21, 2020 at 17:23
  • please provide sample data Commented Jan 21, 2020 at 17:24
  • @YOLO type('t') returns 'str', t is listed as datetime in the variable explorer Commented Jan 21, 2020 at 18:16

1 Answer 1

1

It seems that your column to is a timestamp. To use scatter it must be a float. You can plot scatter plot with:

ax = df_stats.plot(x = 't', y='t_TI_var_pwr',style='o')      
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.