New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis name from Y overwrites axis name X in scatter plots when using formulas. #161

Closed
michalhuflejt opened this Issue Oct 8, 2014 · 9 comments

Comments

2 participants
@michalhuflejt

It seems there's a bug.
Version 0.5.8
File: chart.py
Function: def _write_cat_val_axis(self, args)
Line: 1813, y_axis['data_id']

An attribute from y_axis gets copied into x_axis. The result is that scatter plot has both the axes named the same, after the y_axis. Only occurs with formulas, not with string constants. On my local copy I changed the line 1813 from y_axis['data_id'] to x_axis['data_id'] and it solved the problem.

1810 # Write the axis title elements.
1811 if x_axis['formula'] is not None:
1812 self._write_title_formula(x_axis['formula'],
1813 y_axis['data_id'], # <- I think the bug is here, should be x_axis['data_id']
1814 horiz,
1815 x_axis['name_font'],
1816 x_axis['name_layout'])

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Oct 8, 2014

Owner

Hi Michal,

Could you post a small example program that demonstrates the issue and I'll have a look at it.

Thanks,

John

Owner

jmcnamara commented Oct 8, 2014

Hi Michal,

Could you post a small example program that demonstrates the issue and I'll have a look at it.

Thanks,

John

@jmcnamara jmcnamara self-assigned this Oct 8, 2014

@michalhuflejt

This comment has been minimized.

Show comment
Hide comment
@michalhuflejt

michalhuflejt Oct 9, 2014

import xlsxwriter

workbook = xlsxwriter.Workbook('bug.xlsx')
worksheet = workbook.add_worksheet('Sheet1')
worksheet.write('A1', 'X')
worksheet.write('B1', 'Y')
worksheet.write('A2', 1.0)
worksheet.write('A3', 3.0)
worksheet.write('B2', 10.0)
worksheet.write('B3', 30.0)

chart = workbook.add_chart({'type': 'scatter'})
chart.add_series({
'name':       'chart with a bug',
'categories': '=Sheet1!$A$1:$A$3',
'values':     '=Sheet1!$B$1:$B$3',
'marker':     {'type': 'circle', 'size': 1}, 
})

chart.set_x_axis({'name': '=Sheet1!$A$1'})
chart.set_y_axis({'name': '=Sheet1!$B$1','major_gridlines': {'visible': False}})

worksheet.insert_chart('E1', chart)
workbook.close()
import xlsxwriter

workbook = xlsxwriter.Workbook('bug.xlsx')
worksheet = workbook.add_worksheet('Sheet1')
worksheet.write('A1', 'X')
worksheet.write('B1', 'Y')
worksheet.write('A2', 1.0)
worksheet.write('A3', 3.0)
worksheet.write('B2', 10.0)
worksheet.write('B3', 30.0)

chart = workbook.add_chart({'type': 'scatter'})
chart.add_series({
'name':       'chart with a bug',
'categories': '=Sheet1!$A$1:$A$3',
'values':     '=Sheet1!$B$1:$B$3',
'marker':     {'type': 'circle', 'size': 1}, 
})

chart.set_x_axis({'name': '=Sheet1!$A$1'})
chart.set_y_axis({'name': '=Sheet1!$B$1','major_gridlines': {'visible': False}})

worksheet.insert_chart('E1', chart)
workbook.close()
@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Oct 9, 2014

Owner

Hi Michal,

Thanks for that. A sample program is always clearer when discussing an issue.

However, I'm not seeing an issue where both axes have the same name in Excel 2011 for Mac (I'll check with other versions later):

untitled

Is this the output that you expect to see or am I missing something. Also, what version of Excel and the XlsxWriter module are you using?

John

Owner

jmcnamara commented Oct 9, 2014

Hi Michal,

Thanks for that. A sample program is always clearer when discussing an issue.

However, I'm not seeing an issue where both axes have the same name in Excel 2011 for Mac (I'll check with other versions later):

untitled

Is this the output that you expect to see or am I missing something. Also, what version of Excel and the XlsxWriter module are you using?

John

@jmcnamara jmcnamara added the question label Oct 9, 2014

@michalhuflejt

This comment has been minimized.

Show comment
Hide comment
@michalhuflejt

michalhuflejt Oct 9, 2014

My code does not insert points (1,0), (2,10) as in your plot. There should be two dots (1,10) and (3,30). I have xlsxwriter 0.5.8 and LibreOffice 3.5 on Ubuntu.
libreoffice3

My code does not insert points (1,0), (2,10) as in your plot. There should be two dots (1,10) and (3,30). I have xlsxwriter 0.5.8 and LibreOffice 3.5 on Ubuntu.
libreoffice3

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Oct 9, 2014

Owner

My code does not insert points (1,0), (2,10) as in your plot.

It does, because I ran your code to generate the plot. :-)

Perhaps the issue is that the ranges are wrong. I think this:

'categories': '=Sheet1!$A$1:$A$3',
'values':     '=Sheet1!$B$1:$B$3',

should be:

'categories': '=Sheet1!$A$2:$A$3',
'values':     '=Sheet1!$B$2:$B$3',

Which gives:

untitled

Owner

jmcnamara commented Oct 9, 2014

My code does not insert points (1,0), (2,10) as in your plot.

It does, because I ran your code to generate the plot. :-)

Perhaps the issue is that the ranges are wrong. I think this:

'categories': '=Sheet1!$A$1:$A$3',
'values':     '=Sheet1!$B$1:$B$3',

should be:

'categories': '=Sheet1!$A$2:$A$3',
'values':     '=Sheet1!$B$2:$B$3',

Which gives:

untitled

@michalhuflejt

This comment has been minimized.

Show comment
Hide comment
@michalhuflejt

michalhuflejt Oct 9, 2014

No matter how I start the series, from 1 or from 2, in both cases I get the same plot. What is important in both cases is that the label for x axis is wrong. I have "Y" on both axes, because the code in chart.py ignores the formula for X and copies it from Y instead, line 1813. Could you please include a correction in the next version ?

No matter how I start the series, from 1 or from 2, in both cases I get the same plot. What is important in both cases is that the label for x axis is wrong. I have "Y" on both axes, because the code in chart.py ignores the formula for X and copies it from Y instead, line 1813. Could you please include a correction in the next version ?

@jmcnamara jmcnamara added bug and removed question labels Oct 9, 2014

jmcnamara added a commit that referenced this issue Oct 9, 2014

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Oct 9, 2014

Owner

Hi Michal,

I was eventually able to reproduce the issue.

I've pushed a fix and test. The change will be in the next release.

Thank you for reporting it.

John

Owner

jmcnamara commented Oct 9, 2014

Hi Michal,

I was eventually able to reproduce the issue.

I've pushed a fix and test. The change will be in the next release.

Thank you for reporting it.

John

@michalhuflejt

This comment has been minimized.

Show comment
Hide comment
@michalhuflejt

michalhuflejt Oct 10, 2014

Very good ! Thank you !

Very good ! Thank you !

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Oct 11, 2014

Owner

Fixed in release 0.5.9.

Thank you for reporting.

Owner

jmcnamara commented Oct 11, 2014

Fixed in release 0.5.9.

Thank you for reporting.

@jmcnamara jmcnamara closed this Oct 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment