|
Angular axis colour in polar plot |
Posted by Rob Ashdown on Jan-06-2009 20:06 |
|
Hi
Is there a way to set the colour of the angular axis on a polar plot? I can't see anything anywhere in the documentation for the AngularAxis object. RadialAxis has setColor - is there something similar?
I'm using version 4.1 - python API.
Apart from that, I must say i am very impressed by Chart Director, very intuitive and flexible.
Thanks,
Rob |
Re: Angular axis colour in polar plot |
Posted by Rob Ashdown on Jan-06-2009 20:54 |
|
Sorry, I found the solution to the initial problem (by using setGridColor).
However it has brought to light another issue, which I need help with.
The following code produces the attached spider diagram, however the data labels are getting obscured by the axes. Also there is a grey 1 pixel line in the first angular axis.
Any ideas how I can fix this? Is the order of the calls to add layers significant?
Thanks,
Rob
from pychartdir import *
# The data for the chart
data = [5.2, 6.6, 2.9, 5.2, 6, 5.2]
labels = ["Label1", "Label2", "Label3", "Label4", "Label5", "Label6"]
# Create a PolarChart object of size 450 x 350 pixels
c = PolarChart(550, 550)
c.setStartAngle(30)
# Set center of plot area at (225, 185) with radius 150 pixels
c.setPlotArea(275, 275, 180)
c.setGridColor(0xffffff,3,0xffffff,1)
c.radialAxis().setLinearScale(10,0, -2.5)
c.radialAxis().setColors(0xc0000000L, Transparent)
# Color the region between radius = 40 to 80 as green (99ff99)
c.radialAxis().addZone(0,2.5, 0x7777ff)
c.radialAxis().addZone(2.5,5, 0x9999ff)
c.radialAxis().addZone(5,7.5, 0xbbbbff)
c.radialAxis().addZone(7.5,10, 0xddddff)
c.addAreaLayer(data, 0xeeee00eeL, "Risk Area")
layer = c.addLineLayer(data, 0xff0000)
layer.setLineWidth(3)
layer.setDataSymbol(CircleShape, 11, 0xffffff)
layer.setDataLabelFormat("{value}")
layer.setDataLabelStyle("arialbd.ttf",9,0x000000)
# Set the labels to the angular axis as spokes
c.angularAxis().setLabels(labels)
c.angularAxis().setLabelStyle("arial.ttf", 8, 0x000000)
# output the chart
c.makeChart("hr_spider.png")
|
Re: Angular axis colour in polar plot |
Posted by Peter Kwan on Jan-07-2009 01:19 |
|
Hi Rob,
The grid line can be set to drawn behind the chart contents by using PolarChart.setGridStyle. For example:
# polygon grid, grid behind chart contents
c.setGridStyle(1, 0)
For the grey 1 pixel line, it is the radial axis (currently set to semi-transparent black 0xc0000000, which will appear as grey when drawn on a white background). To disable the grey 1 pixel line, you may set the radial axis to transparent.
c.radialAxis().setColors(Transparent, Transparent)
Hope this can help.
Regards
Peter Kwan |
Re: Angular axis colour in polar plot |
Posted by Rob Ashdown on Jan-07-2009 01:24 |
|
Peter
Thank you. That all works perfectly now.
Rob |
|