Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 589445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:25:30+00:00 2026-05-13T15:25:30+00:00

Given this 3D bar graph sample code , how would you convert the numerical

  • 0

Given this 3D bar graph sample code, how would you convert the numerical data in the x-axis to formatted date/time strings? I’ve attempted using the ax.xaxis_date() function without success. I also tried using plot_date(), which doesn’t appear to work for 3D bar graphs. Here is a modified version of the sample code to illustrate what I am trying to do:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.dates as dates

dates = [dates.date2num(datetime.datetime(2009,3,12)),
         dates.date2num(datetime.datetime(2009,6,9)),
         dates.date2num(datetime.datetime(2010,1,1)),
         #etc...
         ]

fig = plt.figure()
ax = Axes3D(fig)
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
    xs = np.array(dates)
    ys = np.random.rand(20)
    ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8)

ax.set_xlabel('Date & Time')
ax.set_ylabel('Series')
ax.set_zlabel('Amount')

plt.show()

alt text

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:25:30+00:00Added an answer on May 13, 2026 at 3:25 pm

    There might be some confusion here, the Axes3D has the properties w_xaxis, w_yaxis and w_zaxis for the axises instead of the usual x-axis, y-axis, etc.

    Tested in python 3.8.11, matplotlib 3.4.3

    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    import numpy as np
    import matplotlib.dates as dates
    import datetime, random
    import matplotlib.ticker as ticker
    
    def random_date():
        date = datetime.date(2008, 12, 1)
        while 1:
            date += datetime.timedelta(days=30)
            yield (date)
    
    def format_date(x, pos=None):
        return dates.num2date(x).strftime('%Y-%m-%d') #use FuncFormatter to format dates
    
    r_d = random_date()
    some_dates = [dates.date2num(next(r_d)) for i in range(0,20)]
    
    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(projection='3d')
    
    for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
        xs = np.array(some_dates)
        ys = np.random.rand(20)
        ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8,width=8)
    
    ax.w_xaxis.set_major_locator(ticker.FixedLocator(some_dates)) # I want all the dates on my xaxis
    ax.w_xaxis.set_major_formatter(ticker.FuncFormatter(format_date))
    for tl in ax.w_xaxis.get_ticklabels(): # re-create what autofmt_xdate but with w_xaxis
        tl.set_ha('right')
        tl.set_rotation(30)     
    
    ax.set_ylabel('Series')
    ax.set_zlabel('Amount')
    
    plt.show()
    

    Produces:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Assuming your button has an instance name of "myButton", on… May 13, 2026 at 7:15 pm
  • Editorial Team
    Editorial Team added an answer if any(s in line for s in ('string1', 'string2', ...)): May 13, 2026 at 7:15 pm
  • Editorial Team
    Editorial Team added an answer The UIActionSheetDelegate method – actionSheet:didDismissWithButtonIndex: is what you're looking for.… May 13, 2026 at 7:15 pm

Related Questions

I have a base class Foo that has an Update() function, which I want
I am thinking of implementing a ribbon GUI in one of my apps and
I'm trying to implement a geometry templating engine. One of the parts is taking
The curve-fitting problem for 2D data is well known (LOWESS, etc.) but given a
Given a path expressed as an array of 2d points: Point[] path = new

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.