Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python XlsxWriter chart : x-axis value labels angle orientation

I have just discovered the website for the Python API : XlsxWriter. I am specifically looking at the Chart creation aspect. I found an example with Date type on the x-axis and in the example the dates are oriented 45 deg with respect to the horizontal: http://xlsxwriter.readthedocs.org/example_chart_date_axis.html

But, when I look at the code below it, I do not see reference to how to control the angle. For example if I wanted the dates oriented at 30 degrees instead.

Is there a function or method that controls the orientation such that a programmer can specify the desired angle?

I found this article on Stack Overflow: Modify chart label orientation with XlsxWriter module (Python). The developer mentions "Chart axis font orientation", but I am not sure if this is what controls the date labels on the x-axis.

like image 253
Palu Avatar asked Oct 20 '25 05:10

Palu


1 Answers

I do not see reference to how to control the angle. For example if I wanted the dates oriented at 30 degrees instead.

Excel rotates date values automatically when necessary (which is the case in the example that you linked to).

However, you can control the rotation yourself as a font property (like in Excel):

chart.set_x_axis({'num_font':  {'rotation': 45}})

See the Chart Fonts section of the docs.

like image 166
jmcnamara Avatar answered Oct 21 '25 20:10

jmcnamara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!