Skip to content
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

Scale issue in matplotlib 2.2 #289

Closed
castillohair opened this issue Jul 10, 2018 · 2 comments
Closed

Scale issue in matplotlib 2.2 #289

castillohair opened this issue Jul 10, 2018 · 2 comments

Comments

@castillohair
Copy link
Collaborator

castillohair commented Jul 10, 2018

Plotting in log scale does not work in matplotlib 2.2. The following statement:

FlowCal.plot.hist1d(d,
                    channel='FL1',
                    xscale='log')

Causes the following error

  File "FlowCal/FlowCal/plot.py", line 936, in hist1d
    plt.gca().set_xscale(xscale, data=data_list, channel=channel)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_base.py", line 3183, in set_xscale
    ax.xaxis._set_scale(value, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axis.py", line 768, in _set_scale
    self._scale = mscale.scale_factory(value, self, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/scale.py", line 570, in scale_factory
    return _scale_mapping[scale](axis, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/scale.py", line 252, in __init__
    "{!r}".format(kwargs))
ValueError: provided too many kwargs, can only pass {'basex', 'subsx', nonposx'} or {'basey', 'subsy', nonposy'}.  You passed {'data': [FCSData([[  0.        , 248.04544143,  57.77217924, ...,  32.48768383,
           99.        , 356.        ],
         [  0.        , 230.82415268,  40.31519363, ...,   2.54829675,
            0.        ,  26.        ],
         [  0.        , 319.08489806,  60.97562352, ...,  18.93842027,
           40.        , 124.        ],
         ...,
         [220.        , 174.65760477,  34.91151937, ...,  25.25478933,
           41.        ,  81.        ],
         [220.        , 449.10071863,  66.11690262, ...,  27.88126665,
           51.        , 104.        ],
         [220.        , 316.22776602,  41.0469838 , ...,  18.93842027,
           14.        ,  66.        ]])], 'channel': 'FL1'}

The following line:

plt.gca().set_xscale(xscale, data=data_list, channel=channel)

Is called to set the axis scale, and additional arguments are passed to the underlying Scale object. data and channel were necessary for logicle to work properly, and it seems that objects related to the logarithmic scals just ignored them. But now it's not ignoring them and crashing instead.

EDIT: Linear scale works, but following the logic here it may not work in the future.

@castillohair
Copy link
Collaborator Author

castillohair commented Jul 10, 2018

The following script:

import FlowCal

d = FlowCal.io.FCSData('Data002.fcs')
d = FlowCal.transform.to_rfi(d)

for scale in ['linear', 'log', 'logicle']:
    # hist1d
    FlowCal.plot.hist1d(d,
                        channel='FL1',
                        xscale=scale,
                        savefig='hist_{}.png'.format(scale))

    # density2d
    FlowCal.plot.density2d(d,
                           mode='scatter',
                           channels=['FSC', 'SSC'],
                           xscale=scale,
                           yscale=scale,
                           savefig='density2d_{}.png'.format(scale))

    # scatter
    FlowCal.plot.scatter2d(d,
                           channels=['FL1', 'FL3'],
                           xscale=scale,
                           yscale=scale,
                           savefig='scatter2d_{}.png'.format(scale))

Run against this file fails with matplotlib 2.2.2, on current branch contour-scikit-image (801f9af) (can't test this with develop because this branch fails with matplotlib 2.2 for other reasons, see #284). The error is the same as above.

@castillohair
Copy link
Collaborator Author

castillohair commented Jul 10, 2018

Commit 1aae4d6 fixes this issue. The script above can run without issues even with matplotlib 2.2.2, and the resulting images are as expected. I'll submit a PR.

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

No branches or pull requests

1 participant