Python Forum
Matplotlib scatter plot slider with datetime
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matplotlib scatter plot slider with datetime
#1
I have a matplotlib scatter plot with dates on the x axis, that updates with a slider, very similar to the example linked here. Per this example, I had been using np.vstack(), but with my dates converted into floats. That worked fine.

xx = np.vstack((df['date'], df['cups']))
scat.set_offsets(xx.T)
However, I am now passing datetime objects to the scatter plot, so that my x axis shows dates instead of floats, and this seems to break np.vstack(), since it requires the numpy array to have mixed datatypes.

As I understand it, the purpose of using vstack is to get the data in the right shape for set_offsets. Since the end-goal is to call set_offsets with the right kind of structure, the solution need not use vstack. However, I'm just not sure how to get the structure that set_offsets requires without using vstack.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pick a line in a plot with matplotlib Romain 3 5,649 Feb-28-2023, 11:56 AM
Last Post: get2sid
  Matplotlib scatter plot in loop with None values ivan_sc 1 2,280 Nov-04-2021, 11:25 PM
Last Post: jefsummers
  New to Python & Matplotlib - can I change the plot grid origin to lower left corner? FortyTwo 1 6,206 Aug-22-2020, 08:22 PM
Last Post: matador
  matplotlib creating a scatter plot via PathCollection tpourjalali 0 2,486 Apr-11-2020, 05:59 PM
Last Post: tpourjalali
  How to add lables to the scatter plot? Jack_Sparrow 3 3,284 Dec-11-2019, 10:20 PM
Last Post: Larz60+
  How to create correct scatter plot for PCA? LK91 0 2,120 Dec-11-2019, 07:53 PM
Last Post: LK91
  It doesn't show scatter plot but it says: "<Figure size 640x480 with 1 Axes>" dcardonaa 0 3,508 Oct-10-2019, 02:34 AM
Last Post: dcardonaa
  MatPlotLib 2d plot of current density? ruben 0 2,208 May-13-2019, 06:47 AM
Last Post: ruben
  Bar Plot with Python ,matplotlib and sqlite3 tables gauravbhardwajee 0 4,971 Sep-25-2018, 06:17 PM
Last Post: gauravbhardwajee
  Draw a square-aspect log-linear plot via matplotlib Antonio 4 8,427 Jun-19-2018, 05:57 PM
Last Post: Antonio

Forum Jump:

User Panel Messages

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