Python Forum
Points not plotting with reference to x-tick labels
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Points not plotting with reference to x-tick labels
#1
Here's the graphing portion of my program:
fig, axs = plt.subplots(1,1) 
fig.set_size_inches(14, 6)

axs.plot(trade_list,P_price_orig_all, marker='o', color='orange')
ax1twin = axs.twinx()
ax1twin.plot(btstats['Date'],btstats['SPX'],marker='',color='blue',linestyle='solid') #May still have to include y-axis label.
axs.set_xticks(list(np.linspace(1,len(btstats.index),num=len(xtick_labels_converted))),xtick_labels_converted, rotation=45)

plt.show()
I spend all those hours figuring out L7 to get evenly spaced (in time) dates to print out evenly spaced across the x-axis. However, trade_list (a list of dates) is not evenly spaced in time. These points print out evenly spaced--not in reference to the date values now shown on the x-axis:

https://ibb.co/z7021yD

What have I done?

Incidentally, if I comment out L5, the blue line goes away and the orange line/markers get compressed on the left side of the graph. This make some sense because len(trade_list) is 255 and len(btstats['SPX']) is 3449. I just want the 255 points to print accordingly where their x-values match up with those on the x-axis.
Reply


Messages In This Thread
Points not plotting with reference to x-tick labels - by Mark17 - Jun-14-2022, 03:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to get evenly-spaced datetime tick labels regardless of x-values of data points? Mark17 4 5,469 Apr-04-2022, 07:10 PM
Last Post: Mark17
  Floor division problem with plotting x-axis tick labels Mark17 5 2,246 Apr-03-2022, 01:48 PM
Last Post: Mark17
  How to define a variable in Python that points to or is a reference to a list member JeffDelmas 4 2,769 Feb-28-2021, 10:38 PM
Last Post: JeffDelmas
  Only show every nth tick in chart tgottsc1 1 4,803 Feb-01-2021, 04:30 PM
Last Post: j.crater
  Complex X Tick Interval JoeDainton123 0 1,526 Oct-05-2020, 07:27 PM
Last Post: JoeDainton123
  Setting Tick Intervals In Sub Plots JoeDainton123 1 1,868 Oct-03-2020, 11:52 PM
Last Post: scidam
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,637 Sep-07-2020, 08:02 AM
Last Post: perfringo
  Vpython Delay in plotting points SohaibAJ 0 2,123 Jul-30-2018, 08:44 PM
Last Post: SohaibAJ
  matplotlib barh y tick alignment iFunKtion 2 7,748 Oct-06-2016, 11:46 AM
Last Post: iFunKtion

Forum Jump:

User Panel Messages

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