Changeset 3316


Ignore:
Timestamp:
06/02/08 14:24:40 (12 years ago)
Author:
mkochan
Message:

Changed x-axis labelling in point series graphing to show times.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/pylonsstack/pylonsstack/controllers/csmlGrapher.py

    r3290 r3316  
    4747            print times 
    4848             
    49             #!span = dates.date2num(times[-1]) - dates.date2num(times[0]) 
    50             #!print 'The span is ' + span + ' days.' 
    51             elapsed_times = map(pylab.matplotlib.dates.datestr2num, times) 
    52             #!(tickLocator, tickFormatter) = dates.date_ticker_factory(span, 5) 
    53              
     49            start_date = dates.dateutil.parser.parse(times[0]) 
     50            end_date = dates.dateutil.parser.parse(times[-1]) 
     51            span = datestr2num(times[-1]) - datestr2num(times[0]) 
     52            print 'The span is ' + str(span) + ' days.' 
     53 
     54            elapsed_times = map(datestr2num, times) 
     55 
     56            (tickLocator, tickFormatter) = dates.date_ticker_factory(span, numticks=8) 
     57            print 'tickLocator:%s\ntickFormatter:%s' % (tickLocator, tickFormatter) 
     58 
    5459            print 'All times (%s of them) as days since 01-01-0001 UTC: '% len(elapsed_times) 
    5560            print elapsed_times 
     
    7277 
    7378            # Plot the figure 
    74             clf() 
    75             #!plot_date(elapsed_times, vals, '-', xdate=True, lw=2) 
    76             plot(elapsed_times, vals, '-', lw=2) 
    77             xlabel('Time since start [days]') 
     79            fig = figure() 
     80            plot_date(elapsed_times, vals, '-', xdate=True, lw=2) 
     81            ax = gca() 
     82            ml = ax.xaxis.get_major_locator() 
     83            ax.xaxis.set_major_locator(tickLocator) 
     84            ax.xaxis.set_major_formatter(tickFormatter) 
     85            fig.autofmt_xdate() 
     86            time_format = '%d-%b-%Y, %H:%M:%S' 
     87            xlabel('Times between %s and %s' % (start_date.strftime(time_format), end_date.strftime(time_format))) 
    7888            ylabel('Values [%s]' % uom) 
    79             title('Plot of "%s" (%s)' % (feature.id, feature.description.CONTENT)) 
     89            title('"%s" (%s)' % (feature.id, feature.description.CONTENT)) 
    8090            grid(True) 
    8191 
     
    97107             
    98108        def _wget(url): 
     109            '''Auxiliary function, returns data read from an URL''' 
    99110            content = None 
    100111            try: 
     
    144155            raise HTTPNotFound('Feature not found') 
    145156             
     157        # Try to plot the feature into a temporary file, and put the contents of that file into the WSGI response 
    146158        try: 
    147159            tempFile = _plot_feature(feature)              # plot the feature into a temporary file 
Note: See TracChangeset for help on using the changeset viewer.