Ignore:
Timestamp:
01/02/10 13:11:23 (11 years ago)
Author:
pnorton
Message:

Made several changes to try and improve the layout of the plot. Also introduced rotating axis labels to avoid labels being drawn on top of each other.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qesdi/linplot/trunk/tests/linplot_tests/draw/draw_named_index.py

    r6318 r6446  
    1111from linplot_tests.draw import getDrawOutputDir, SHORT_LOG_FORMAT_STRING 
    1212 
    13 def draw_named_index(): 
     13from common import getData, seed 
     14import random 
     15log = logging.getLogger(__name__) 
     16 
     17def draw_named_index_short(): 
    1418     
    15     fileName = 'named_index.png' 
     19    fileName = 'named_index_short.png' 
    1620    outputDir = getDrawOutputDir() 
    1721    outputFile = os.path.join(outputDir, fileName) 
     
    4751    print "Wrote %s" % (outputFile) 
    4852     
     53def draw_named_index_long(): 
     54     
     55     
     56    fileName = 'named_index_long.png' 
     57    outputDir = getDrawOutputDir() 
     58    outputFile = os.path.join(outputDir, fileName) 
     59     
     60    l = [ "scheme with long name %s" % (x,) for x in ['A','B','C','D','E','F' ]] 
     61     
     62    plt = Plot() 
     63    nlines = 3 
     64     
     65    # set the order of the labels to be used 
     66    plt.addXAxisIndexValues(l) 
     67 
     68    for i in range(nlines): 
     69        nItems = random.randint(2, len(l)) 
     70         
     71        xdata = numpy.array(random.sample(l, nItems)) 
     72        xdata.sort() 
     73        ydata = getData(len(xdata)) 
     74        label="model number %s" % (i,) 
     75        log.debug("label= %s, xdata = %s, ydata = %s" % (label, xdata, ydata,)) 
     76        plt.draw(xdata, ydata, label=label) 
     77         
     78    plt.setXLabel('X - year') 
     79    plt.setYLabel('Y - temp') 
     80         
     81    plt.saveImage(outputFile) 
     82    print "Wrote %s" % (outputFile) 
     83 
     84def draw_named_index(s=None): 
     85    seed(s) 
     86    draw_named_index_short() 
     87    draw_named_index_long() 
    4988 
    5089if __name__ == '__main__': 
    5190     
     91     
    5292    logging.basicConfig(level=logging.DEBUG, format=SHORT_LOG_FORMAT_STRING) 
    5393    draw_named_index() 
Note: See TracChangeset for help on using the changeset viewer.