Hi Eva,
You may create multiple XYChart objects, and put them together in a MultiChart container.
Below is an example. In the code, the drawChart function is used to draw an XYChart. I have configured the chart so that its ticks are pointing inwards, and there are ticks at the 4 sides of the plot area. The drawChart is called multiple times, and a MultiChart object is used to combine the charts into a single image.
#!/usr/bin/python
from pychartdir import *
def drawChart(data, needXLabel, yTitle) :
c = XYChart(600, 200, Transparent)
c.setPlotArea(55, 0, 520, 150).setGridColor(0xcccccc, 0xcccccc)
layer = c.addLineLayer(data, 0x0000ff)
layer.setLineWidth(2)
layer.setXData(xCoor)
c.xAxis().setTickLength(-5)
c.xAxis2().setTickLength(-5)
c.xAxis2().syncAxis(c.xAxis())
if not needXLabel :
c.xAxis().setLabelFormat(" ")
c.yAxis().setMargin(15, 15)
c.yAxis2().syncAxis(c.yAxis())
c.yAxis().setTickLength(-5)
c.yAxis2().setTickLength(-5)
c.yAxis2().setTitle(yTitle)
c.yAxis2().setLabelFormat(" ")
return c
# The data for the line chart
data0 = [42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60, 70,
76, 63, 67, 75, 64, 51, 77]
data1 = [50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73,
77, 84, 82, 80, 84, 98, 82]
data2 = [36, 28, 25, 33, 38, 20, 22, 30, 25, 33, 30, 24, 28, 15, 21, 26, 46, 42, 48,
45, 43, 52, 64, 60, 70, 56]
xCoor = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25]
m = MultiChart(600, 520)
m.addTitle("ABCD EFGH", "arialbd.ttf", 8)
m.addChart(0, 20, drawChart(data0, 0, "AAA"))
m.addChart(0, 170, drawChart(data1, 0, "BBB"))
m.addChart(0, 320, drawChart(data2, 1, "CCC"))
m.makeChart("test.png")
Hope this can help.
Regards
Peter Kwan |