[reportlab-users] Re: Plotting with logarithmic axes
Berthold Höllmann
reportlab-users@reportlab.com
Thu, 24 Jul 2003 15:57:15 +0200
--=-=-=
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
hoel@gl-group.com (Berthold Höllmann) writes:
> "Andy Robinson" <andy@reportlab.com> writes:
>
...
>
> OK, it involved a little more than just the scale function. I'll
> attach my first version.
I hope this stuff is usefull for somebody else. I worked a little more
on the code, deleted surplus stuff and added minor tics for the
logarithmic axes. Would they be accepted for linear axes also? If yes,
I will try to provide a patch. I'll attach a new version of my
logarithmic axes for LinePlot. It comes with some examples.
Regards
Berthold
--
Dipl.-Ing. Berthold Höllmann __ Address:
hoel@GL-Group.com G / \ L Germanischer Lloyd
phone: +49-40-36149-7374 -+----+- Vorsetzen 32/35 P.O.Box 111606
fax : +49-40-36149-7320 \__/ D-20459 Hamburg D-20416 Hamburg
--=-=-=
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=logaxis.py
Content-Transfer-Encoding: base64
IyEgL2Jpbi9lbnYgcHl0aG9uCiMgLSotIGNvZGluZzogaXNvLWxhdGluLTEgLSotCgojIENvcHly
aWdodCAoQykgMjAwMyBieSBHZXJtYW5pc2NoZXIgTGxveWQKCiMgJEhlYWRlciQKIwojIFRpbWUt
c3RhbXA6IDwyMDAzLTA3LTI0IDE1OjU0OjA2IGhvZWw+CiMKIyA9PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiMgTW9k
dWxlICAgIGxvZ2F4aXMKIyBUYXNrICAgICAgUHJvdmlkZXMgbG9nYXJpdGhtaWMgYXhlcyBmb3Ig
UmVwb3J0bGFiIExpbmVQbG90IGNsYXNzCiMgLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQojIEF1dGhvciAgICBCZXJ0
aG9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fYXR0
ck1hcCA9IEF0dHJNYXAoCiAgICAgICAgQkFTRT1Mb2dWYWx1ZUF4aXMsCiAgICAgICAgdGlja1Vw
ID0gQXR0ck1hcFZhbHVlKGlzTnVtYmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBk
ZXNjPSdUaWNrIGxlbmd0aCB1cCB0aGUgYXhpcy4nKSwKICAgICAgICB0aWNrRG93biA9IEF0dHJN
YXBWYWx1ZShpc051bWJlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNjPSdU
aWNrIGxlbmd0aCBkb3duIHRoZSBheGlzLicpLAogICAgICAgIG10aWNrVXAgPSBBdHRyTWFwVmFs
dWUoaXNOdW1iZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M9J01pbm9yIHRp
Y2sgbGVuZ3RoIHVwIHRoZSBheGlzLicpLAogICAgICAgIG10aWNrRG93biA9IEF0dHJNYXBWYWx1
ZShpc051bWJlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNjPSdNaW5vciB0
aWNrIGxlbmd0aCBkb3duIHRoZSBheGlzLicpLAogICAgICAgIGpvaW5BeGlzID0gQXR0ck1hcFZh
bHVlKE5vbmUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzYz0nSm9pbiBib3Ro
IGF4ZXMgaWYgdHJ1ZS4nKSwKICAgICAgICBqb2luQXhpc01vZGUgPSBBdHRyTWFwVmFsdWUoT25l
T2YoJ2JvdHRvbScsICd0b3AnLCAndmFsdWUnLCAncG9pbnRzJywKICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgTm9uZSksCiAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgIGRlc2M9Ik1vZGUgdXNlZCBmb3IgY29ubmVjdGluZyBheGlzICgnYm90dG9tJywg
J3RvcCcsICd2YWx1ZScsICdwb2ludHMnLCBOb25lKS4iKSwKICAgICAgICBqb2luQXhpc1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