DISLIN bar chart labels

Helmut Michels michels at linmpi.mpg.de
Wed Nov 8 03:33:46 EST 2000


stevecanfield at my-deja.com wrote:

> I've been playing with DISLIN plotting some bar charts in Python and I
> am having trouble with custom X-axis labels (using the mylab call).
>
> The documentation says only 20 user-defined labels are allowed.  I've
> made a couple of sample graphs and confirmed that it does not print any
> labels after the 20th tick.  Can anybody suggest a workaround?
>
> I have some charts that need approximately 30 bars and DISLIN seems to
> do pretty much exactly what I want, except for the labels problem.
>
> Thanks,
> Steve
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

A workaround is to write the labels directly on the X-axis.  It's very
easy. All you need is the length of the labels in plot units for centering
them,
the position of the labels on the X-axis and the distance of the labels
from the X-axis. The length of labels can be calculated with the function
nlmess, the position of the major ticks on the X-axis can be returned by
nxposn and the default distance of labels from an axis is 48 plot units
(see the functions
ticlen and labdis).
The following example plots the labels 'A1', 'A2', ... 'A10' on the
X-axis.

---------
#!/usr/bin/env python
import dislin

clab = ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10']

dislin.metafl ('cons')
dislin.disini ()
dislin.pagera ()
dislin.complx ()

# suppressing the default labels on the X-axis
dislin.setgrf ('ticks', 'name', 'ticks', 'ticks')
dislin.graf (0., 9., 0., 1., 0., 5., 0., 1.)

ny = dislin.nyposn (0.);
for i in range (0, 10):
  nl = dislin.nlmess (clab[i]);
  nx = dislin.nxposn (i);
  dislin.messag (clab[i], nx - nl/2, ny + 48)

dislin.disfin ()
--------

 Helmut Michels
  Max-Planck-Institut fuer Aeronomie  Phone: +49 5556 979-334
  Max-Planck-Str. 2                   Fax  : +49 5556 979-240
  D-37191 Katlenburg-Lindau           Mail : michels at linmpi.mpg.de
  DISLIN Home Page:  http://www.linmpi.mpg.de/dislin






More information about the Python-list mailing list