[reportlab-users] Re: Plotting with logarithmic axes
Berthold Höllmann
reportlab-users@reportlab.com
Wed, 23 Jul 2003 16:47:04 +0200
--=-=-=
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
"Andy Robinson" <andy@reportlab.com> writes:
>> Hello,
>>
>> Is there any support for plotting Data with one or both axes divided
>> logarithmic in ReportLab graphics?
>>
>> Thanks
>> Berthold
> Not yet, but it should be quite easy to subclass
> the ValueAxis class and add a new scaling function...
> Surprisingly we have never had to do a log plot yet.
OK, it involved a little more than just the scale function. I'll
attach my first version.
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=logplot.py
Content-Transfer-Encoding: base64
IyEgL2Jpbi9lbnYgcHl0aG9uCiMgLSotIGNvZGluZzogaXNvLWxhdGluLTEgLSotCgojIENvcHly
aWdodCAoQykgMjAwMyBieSBHZXJtYW5pc2NoZXIgTGxveWQKCiMgJEhlYWRlciQKIwojIFRpbWUt
c3RhbXA6IDwyMDAzLTA3LTIzIDE2OjQ2OjM2IGhvZWw+CiMKIyA9PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiMgTW9k
dWxlICAgIGxvZ3Bsb3QKIyBUYXNrICAgICAgcGxvdHMgd2l0aCBsb2dhcml0aG1pYyBheGVzIGZv
ciBSZXBvcnRsYWIKIyAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCiMgQXV0aG9yICAgIEJlcnRob2xkIEj2bGxtYW5u
CiMgUHJvamVjdAojIC0tLS0tLS0tLS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ICAgZWxpZiBmIGlz
IHN0ciBhbmQgc2VsZi5fYWxsSW50VGlja3MoKTogZiA9ICclLjBlJwogICAgICAgIHBvcyA9IFtz
ZWxmLl94LCBzZWxmLl95XQogICAgICAgIGQgPSBzZWxmLl9kYXRhSW5kZXgKICAgICAgICBsYWJl
bHMgPSBzZWxmLmxhYmVscwoKICAgICAgICBpID0gMAogICAgICAgIGZvciB0aWNrIGluIHNlbGYu
X3RpY2tWYWx1ZXM6CiAgICAgICAgICAgIGlmIGYgYW5kIGxhYmVsc1tpXS52aXNpYmxlOgogICAg
ICAgICAgICAgICAgdiA9IHNlbGYuc2NhbGUodGljaykKICAgICAgICAgICAgICAgIGlmIHR5cGUo
ZikgaXMgU3RyaW5nVHlwZTogdHh0ID0gZiAlIHRpY2sKICAgICAgICAgICAgICAgIGVsaWYgdHlw
ZShmKSBpbiAoVHVwbGVUeXBlLExpc3RUeXBlKToKICAgICAgICAgICAgICAgICAgICAjaXQncyBh
IGxpc3QsIHVzZSBhcyBtYW55IGl0ZW1zIGFzIHdlIGdldAogICAgICAgICAgICAgICAgICAgIGlm
IGkgPCBsZW4oZik6CiAgICAgICAgICAgICAgICAgICAgICAgIHR4dCA9IGZbaV0KICAgICAgICAg
ICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgICAgICAgICB0eHQgPSAnJwogICAgICAg
ICAgICAgICAgZWxpZiBjYWxsYWJsZShmKToKICAgICAgICAgICAgICAgICAgICB0eHQgPSBmKHRp
Y2sqKjEwLikKICAgICAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICAgICAgcmFpc2Ug
VmFsdWVFcnJvciwgJ0ludmFsaWQgbGFiZWxUZXh0Rm9ybWF0ICVzJyAlIGYKICAgICAgICAgICAg
ICAgIGxhYmVsID0gbGFiZWxzW2ldCiAgICAgICAgICAgICAgICBwb3NbZF0gPSB2CiAgICAgICAg
ICAgICAgICBhcHBseShsYWJlbC5zZXRPcmlnaW4scG9zKQogICAgICAgICAgICAgICAgbGFiZWwu
c2V0VGV4dCh0eHQpCiAgICAgICAgICAgICAgICBnLmFkZChsYWJlbCkKICAgICAgICAgICAgaSA9
IGkgKyAxCgogICAgICAgIHJldHVybiBnCgoKY2xhc3MgTG9nWFZhbHVlQXhpcyhMb2dWYWx1ZUF4
aXMsWFZhbHVlQXhpcyk6CiAgICBfYXR0ck1hcCA9IEF0dHJNYXAoCiAgICAgICAgQkFTRT1Mb2dW
YWx1ZUF4aXMsCiAgICAgICAgdGlja1VwID0gQXR0ck1hcFZhbHVlKGlzTnVtYmVyLAogICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICBkZXNjPSdUaWNrIGxlbmd0aCB1cCB0aGUgYXhpcy4nKSwK
ICAgICAgICB0aWNrRG93biA9IEF0dHJNYXBWYWx1ZShpc051bWJlciwKICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICBkZXNjPSdUaWNrIGxlbmd0aCBkb3duIHRoZSBheGlzLicpLAogICAg
ICAgIGpvaW5BeGlzID0gQXR0ck1hcFZhbHVlKE5vbmUsCiAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgZGVzYz0nSm9pbiBib3RoIGF4ZXMgaWYgdHJ1ZS4nKSwKICAgICAgICBqb2luQXhp
c01vZGUgPSBBdHRyTWFwVmFsdWUoT25lT2YoJ2JvdHRvbScsICd0b3AnLCAndmFsdWUnLCAncG9p
bnRzJywgTm9uZSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M9Ik1v
ZGUgdXNlZCBmb3IgY29ubmVjdGluZyBheGlzICgnYm90dG9tJywgJ3RvcCcsICd2YWx1ZScsICdw
b2ludHMnLCBOb25lKS4iKSwKICAgICAgICBqb2luQXhpc1BvcyA9IEF0dHJNYXBWYWx1ZShpc051
bWJlck9yTm9uZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNjPSdQb3Np
dGlvbiBhdCB3aGljaCB0byBqb2luIHdpdGggb3RoZXIg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ck1hcFZhbHVlKE9uZU9mKCgnbGVmdCcsICdyaWdodCcsICd2
YWx1ZScsICdwb2ludHMnLCBOb25lKSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgIGRlc2M9Ik1vZGUgdXNlZCBmb3IgY29ubmVjdGluZyBheGlzICgnbGVmdCcsICdyaWdodCcs
ICd2YWx1ZScsICdwb2ludHMnLCBOb25lKS4iKSwKICAgICAgICBqb2luQXhpc1BvcyA9IEF0dHJN
YXBWYWx1ZShpc051bWJlck9yTm9uZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICBkZXNjPSdQb3NpdGlvbiBhdCB3aGljaCB0byBqb2luIHdpdGggb3RoZXIgYXhpcy4nKSwKICAg
ICAgICApCiAgICBkZWYgX19pbml0X18oc2VsZik6CiAgICAgICAgTG9nVmFsdWVBeGlzLl9faW5p
dF9fKHNlbGYpCiAgICAgICAgc2VsZi5sYWJlbHMuYm94QW5jaG9yID0gJ2UnCiAgICAgICAgc2Vs
Zi5sYWJlbHMuZHggPSAtNQogICAgICAgIHNlbGYubGFiZWxzLmR5ID0gMAoKICAgICAgICBzZWxm
LnRpY2tSaWdodCA9IDAKICAgICAgICBzZWxmLnRpY2tMZWZ0ID0gNQoKICAgICAgICBzZWxmLmpv
aW5BeGlzID0gTm9uZQogICAgICAgIHNlbGYuam9pbkF4aXNNb2RlID0gTm9uZQogICAgICAgIHNl
bGYuam9pbkF4aXNQb3MgPSBOb25lCgogICAgZGVmIHNjYWxlKHNlbGYsIHZhbHVlKToKICAgICAg
ICAiIiJDb252ZXJ0cyBhIG51bWVyaWMgdmFsdWUgdG8gYSBZIHBvc2l0aW9uLgoKICAgICAgICBU
aGUgY2hhcnQgZmlyc3QgY29uZmlndXJlcyB0aGUgYXhpcywgdGhlbiBhc2tzIGl0IHRvCiAgICAg
ICAgd29yayBvdXQgdGhlIHggdmFsdWUgZm9yIGVhY2ggcG9pbnQgd2hlbiBwbG90dGluZwogICAg
ICA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