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

  • Home
  • SEARCH
  • 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 8367001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:03:13+00:00 2026-06-09T13:03:13+00:00

Possible Duplicate: How to plot data against specific dates on the x-axis using matplotlib

  • 0

Possible Duplicate:
How to plot data against specific dates on the x-axis using matplotlib
Plot with non-numerical data on x axis (for ex., dates)

I am attempting to generate a bar graph in matplotlib where the x-axis and y-axis values are tuples of (dates, integers). The data has the following form:

data = [('2012-02-26', 17), ('2012-03-07', 16), ('2012-06-30', 16), 
        ('2012-03-16', 15), ('2012-06-24', 15), ('2012-05-13', 14), 
        ('2012-03-19', 12), ('2012-02-18', 9), ('2012-04-07', 9), 
        ('2012-04-09', 8)]

I can generate a simple bar graph if I simply use integers as x values:

import scipy as sp
from matplotlib import pyplot as pl
x = sp.arange(100)
y = sp.random.randint(1,100, 100)
fig = figure()
pl.bar(x,y)

enter image description here

How can I plot a similar bar graph with string dates on the x-axis? Ideally, I would also like to have the x-axis labels show as dates. I found a similar example on the matplotlib recipe page, but I could not get it to work with my example. Thanks for the help.

  • 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-06-09T13:03:15+00:00Added an answer on June 9, 2026 at 1:03 pm

    Use the plot_date function instead of plot().

    plot_date

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

Sidebar

Related Questions

Possible Duplicate: Plot dates on the x axis and time on the y axis
Possible Duplicate: core-plot remove decimal points from axis labels I 'am building a Scatterplot
Possible Duplicate: Automatically plot different colored lines in MATLAB I have the following data
Possible Duplicate: Using ggplot2, can I insert a break in the axis? I'm using
Possible Duplicate: How to plot two histograms together in R? I want to plot
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How to choose the numbers shown on the axes of a plot
Possible Duplicate: Equation-driven smoothly shaded concentric shapes How could I plot a symmetrical heart
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: I need a good way to get data from a thread to

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.