Change size of a chart within a worksheet

1,043 views
Skip to first unread message

laurent debacker

unread,
Jan 5, 2016, 10:55:06 AM1/5/16
to openpyxl-users
Hi,
I'm trying to resize a chart that I inserted at a given position within a worksheet.
 
I can't get this to work.
 
Anyone knowing how to do this?
 
Thanks,
 
Laurent.
 
------------
 
    c1 = LineChart()
    c1.title = "Square function"
    c1.style = 13
    c1.x_axis.title = 'X'
    c1.y_axis.title = 'Y=f(x)=x^2'
    c1.legend=None
    c1.w=0.5
    c1.h=0.5
    data = Reference(ws1, min_col=2, min_row=1, max_col=2, max_row=7)
    c1.add_data(data, titles_from_data=False)
    # Style the lines
    s1 = c1.series[0]
    s1.marker.symbol = "dot"
    s1.marker.graphicalProperties.solidFill = "FF0000" # Marker filling
    s1.marker.graphicalProperties.line.solidFill = "FF0000" # Marker outline
    #s1.graphicalProperties.line.noFill = True
    s1.graphicalProperties.line.solidFill = "000000"
    ws1.add_chart(c1, "D1")
 
     ????

Charlie Clark

unread,
Jan 5, 2016, 11:00:46 AM1/5/16
to openpyx...@googlegroups.com
Am .01.2016, 16:55 Uhr, schrieb laurent debacker
<laurent....@gmail.com>:

> I'm trying to resize a chart that I inserted at a given position within a
> worksheet.

You probably want to use the `height` and `width` attributes in cm. NB.
this can only ever be approximate because charts actually use a
pixel-based size but this is very difficult to work with. For standard
rows and columns on Windows a column is about 1.5 cm wide and rows are
about 0.5 cm high.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
Message has been deleted

laurent debacker

unread,
Jan 5, 2016, 11:14:32 AM1/5/16
to openpyxl-users
How did I miss this?
 
This works fine.
 
Thanks for the help.
 
Best regards,
 
Laurent
Reply all
Reply to author
Forward
0 new messages