Note that there are some explanatory texts on larger screens.

plurals
  1. POModify chart label orientation with XlsxWriter module (Python)
    text
    copied!<p>I have decided to use XlsxWriter to produce a common output product for many countries. While I am impressed with the modules flexibility, I can't seem to figure out how to modify labels in charts appropriately. The 'text_wrap' capability does not appear to be contained within 'set_x_axis', which results in very long labels rotated at 45 degrees. As can be seen below, I tried to make it happen anyway (just to see what would happen), and the statement is ignored. </p> <pre><code>"""Allow for text wrap for x_axis labels (doesn't seem to do anything)""" chart_list[2].set_x_axis({'text_wrap':True}) </code></pre> <p>The consequence is a chart area that keeps to the specified dimensions at the external boundaries, but the plot area itself is dominated by the label length. Does anyone have an idea of how to do this? Right now, my only (subpar) solution is to decrease the font size and use abbreviations. This brings with it loss of clarity and there is no room for explanatory text.</p> <p>UPDATE: I am including a code block to demonstrate length of labels as requested. (Sorry for the delay, I ended up getting swamped and had to put it down.) You can see the length of the desired labels. They end up coming out diagonal and squishing the chart area. I have not been able to test your fix yet, but I did feel I needed to get back to you with more specifics on what I meant. I'd like those labels to be wrapped instead of diagonal (which I described generally as label orientation). Thanks for taking a look! (And yes, label was incorrect. I meant category label...)</p> <pre><code> """Chart III - Macro-Level Comparisons in Euros &gt;&gt;&gt; (GDP per capita,Average Gross Annual Salary, Government Expenditure per capita) translates to ... Index(Per Capita GDP (Euros), Average gross annual salary (Euros), Public Expenditure Per Capita (€)) DATA: All must be written to new sheet from outdset_build(country) """ #Create list of relevant figures (have to use lev distance because the euro symbol causes match problems) chart3_figures=['Per Capita GDP (Euros)', 'Average gross annual salary (Euros)', 'Public Expenditure Per Capita (€)'] c3_figs=[] for i in range(len(chart3_figures)): figs=process.extract(chart3_figures[i],outdset_build(country).index.get_level_values('figure'),limit=1)[0] c3_figs.append(figs[0]) #Generate subindex to subset data chart3_index=outdset_build(country).index.get_level_values('figure').isin(c3_figs) #Subset data chart3_data=outdset_build(country)[chart3_index] #Create new sheet temp_data=jagx.add_worksheet('misc_data') #Write data to new sheet temp_data.write_row('A1',['index','EU','EU-10','CROATIA']) temp_data.write_column('A2', ['Per Capita GDP','Average Gross Annual Salary', \ 'Public Expenditure Per Capita']) temp_data.write_column('B2',chart3_data['EU']) temp_data.write_column('C2',chart3_data['EU-10']) temp_data.write_column('D2',chart3_data[country]) #Configure series chart_list[2].add_series({ 'name':'EU', 'categories':'misc_data!A2:A4', 'values':'misc_data!B2:B4' }) chart_list[2].add_series({ 'name':'EU-10', 'categories':'misc_data!A2:A4', 'values':'misc_data!C2:C4' }) chart_list[2].add_series({ 'name':'CROATIA', 'categories':'misc_data!A2:A4', 'values':'misc_data!D2:D4' }) #Add title chart_list[2].set_title({'name':'Macro-level Comparison in Euros (per capita)','name_font':{'size':9}}) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload