Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
xticks
#6
I am now working with the same graph, but I would like to get the hours (every 3) between those dates,
but once I write this lines


time_list=[CEU_times[position1].hour() + datetime.timedelta(hours=i) for i in range(0,len(y),3)]
plt.bar(np.arange(len(y[0:-1])),y[0:-1], width=1, color='blue' )

plt.xticks((range(len(y))),(time_list), rotation=90)
gca().xaxis.tick_bottom()
plt.show()
I get the following error:
Error:
runfile('C:/Users/Desktop/python ode/dtnew.py', wdir='C:/Users/Desktop/python ode') Traceback (most recent call last): File "<ipython-input-676-1b5fe841af55>", line 1, in <module> runfile('C:/Users/Desktop/python ode/dtnew.py', wdir='C:/Users/Desktop/python ode') File "C:\Users\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile execfile(filename, namespace) File "C:\Users\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "C:/UsersDesktop/python ode/dtnew.py", line 73, in <module> time_list=[CEU_times[position1].hour() + datetime.timedelta(hours=i) for i in range(0,len(y))] File "C:/Users/Desktop/python ode/dtnew.py", line 73, in <listcomp> time_list=[CEU_times[position1].hour() + datetime.timedelta(hours=i) for i in range(0,len(y))] TypeError: 'int' object is not callable
any idea on why the error and how to fix it?
Reply


Messages In This Thread
xticks - by mcgrim - Jun-06-2019, 09:00 PM
RE: xticks - by mcgrim - Jun-07-2019, 11:32 AM
RE: xticks - by heiner55 - Jun-07-2019, 01:36 PM
RE: xticks - by michalmonday - Jun-07-2019, 01:40 PM
RE: xticks - by Yoriz - Jun-07-2019, 01:56 PM
RE: xticks - by mcgrim - Jun-09-2019, 09:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tell exact difference between xlim() and xticks() function ift38375 3 5,246 Jul-12-2019, 12:04 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020