matplotlib question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • asdf

    matplotlib question

    basically I need to plot a graph of data vs time. However when i use
    matplotlib the hr:min tick marks come out very close together and
    appear jumbled. So 12:00 comes out very close to 12:30 for example.
    There are two things I would like to do. First, is to increase
    the horizontal dimension of the graph. So basically increase the
    horizontal number of pixels. The data will always be from
    midnight to midnight it's just that i want it stretched out
    more horizontally. Also, how do i specify that i only want hourly
    tickmarks. So under the x-axis i only want to see 12:00 1:00 etc.

    thanks
  • Tom Wright

    #2
    Re: matplotlib question

    asdf wrote:
    basically I need to plot a graph of data vs time. However when i use
    matplotlib the hr:min tick marks come out very close together and
    appear jumbled.
    You need to look up the matplotlib.date s package - it's covered briefly in
    the tutorial at http://matplotlib.sourceforge.net/tutorial.html

    At a guess, you want something along the lines of this...

    from matplotlib.date s import YearLocator, MonthLocator, WeekdayLocator, \
    DayLocator, HourLocator, MinuteLocator, SecondLocator, \
    DateFormatter

    subplot.xaxis.s et_major_locato r(HourLocator(r ange(0,24,6)))
    subplot.xaxis.s et_major_format ter(DateFormatt er("%a %H:%M"))
    subplot.xaxis.s et_minor_locato r(HourLocator(r ange(0,24,1)))

    ....but you'll probably need to look up the documentation to get the details
    to suit what you need.

    Hope that helps!


    --
    I'm at CAMbridge, not SPAMbridge

    Comment

    Working...