[Matplotlib-users] matplotlibrc prop_cycle error

Eric Firing efiring at hawaii.edu
Wed Sep 13 21:27:29 EDT 2017


On 2017/09/13 12:17 PM, Emlyn Price wrote:
> Hi,
> 
> I have been trying to set up a custom color cycle in matplotlib using 
> the matplotlibrc file. I have encountered a problem with the default 
> matplotlibrc file provided with the installation from Arch llinux's 
> package manager and the example provided in the online documentation at: 
> https://matplotlib.org/users/customizing.html
> 
> When the lines controlling the axes.prop_cycle are uncommented:
> 
> axes.prop_cycle    : cycler('color',
>                              ['1f77b4', 'ff7f0e', '2ca02c', 'd62728',
>                                '9467bd', '8c564b', 'e377c2', '7f7f7f',
>                                'bcbd22', '17becf'])
> 
> 
> the following message is generated when I import matplotlib:
> 
> /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: 
> UserWarning: Illegal line #338
>      "                            ['1f77b4', 'ff7f0e', '2ca02c', 'd62728',
> "
>      in file "/home/ejp/mpl_test/matplotlibrc"
>    warnings.warn('Illegal %s' % error_details)
> /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: 
> UserWarning: Illegal line #339
>      "                              '9467bd', '8c564b', 'e377c2', '7f7f7f',
> "
>      in file "/home/ejp/mpl_test/matplotlibrc"
>    warnings.warn('Illegal %s' % error_details)
> /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1078: 
> UserWarning: Illegal line #340
>      "                              'bcbd22', '17becf'])
> "
>      in file "/home/ejp/mpl_test/matplotlibrc"
>    warnings.warn('Illegal %s' % error_details)
> /usr/lib/python3.6/site-packages/matplotlib/__init__.py:1120: 
> UserWarning: Bad val "cycler('color'," on line #337
>      "axes.prop_cycle    : cycler('color',
> "
>      in file "/home/ejp/mpl_test/matplotlibrc"
>      Key axes.prop_cycle: 'cycler('color',' is not a valid cycler 
> construction: unexpected EOF while parsing (<string>, line 1)
>    (val, error_details, msg))
> 
> The same error is generated if I import cycler using
> 
> import cycler
> 
> or
> 
> from cycler import cycler
> 
> I am using matplotlib 2.0.2 in python version 3.6.2 installed from the 
> Arch Linux repositories.
> The ouput of uname -a is :Linux tinker 4.12.12-1-ARCH #1 SMP PREEMPT Sun 
> Sep 10 09:41:14 CEST 2017 x86_64 GNU/Linux
> 
> To reproduce:
> 
> Copy the default matplotlibrc
> Uncomment the lines containing
> axes.prop_cycle    : cycler('color',
>                              ['1f77b4', 'ff7f0e', '2ca02c', 'd62728',
>                                '9467bd', '8c564b', 'e377c2', '7f7f7f',
>                                'bcbd22', '17becf'])
> Run python in the directory containing the matplotlibrc file
> Import matplotlib
> 
> Am I missing something obvious?
> Thanks,
> Emlyn

Emlyn,

The matplotlibrc parser is not very smart; it is parsing each line 
independently, but our matplotlibrc.template is giving a commented-out 
example like what you show--with multiple lines to the entry.  This is a 
bug.  The workaround is to concatenate the lines so that the 
axes.prop_cycle entry is a single line.

Thank you for the report, which I have copied to the issue tracker:
https://github.com/matplotlib/matplotlib/issues/9184


Eric


More information about the Matplotlib-users mailing list