You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Manual linestyle specification ignored if 'prop_cycle' contains 'ls' #5875
If the axes.prop_cycle contains the label 'ls' it is not possible to manually specify a linestyle in a plot. However, if axes.prop_cycle contains the label 'linestyle', everything seems to work as expected.
An example showing the problem:
fromcyclerimportcyclerimportmatplotlibasmplimportmatplotlib.pyplotaspltimportnumpyasnpmpl.__version__# ==1.5.1linestyle_cycle=cycler('linestyle', ['-', '--'])
ls_cycle=cycler('ls', ['-', '--'])
x=np.arange(10)
mpl.rcParams['axes.prop_cycle'] =linestyle_cycleplt.figure()
forkinrange(1, 6):
plt.plot(x, k*x)
plt.plot(x, x**2, 'k:') # Black dotted as expectedplt.title('linestyle_cycle')
mpl.rcParams['axes.prop_cycle'] =ls_cycleplt.figure()
forkinrange(1, 6):
plt.plot(x, k*x)
plt.plot(x, x**2, 'k:') # Black dashed - not expectedplt.title('ls_cycle')
This might be the normalization bug we are seeing elsewhere. I have code
that normalizes the key names from 'ls' to 'linestyle', but it seems to
only trigger for cycles defined from the rc file. If a cycle object is
passed in, it just uses it as-is. Unfortunately, I needed that
normalization feature to simplify the cycle advancing feature. The
linestyle given by 'k:' is compared with the properties from the cycler.
Only properties from the cycler that doesn't exist in the manual
specification are taken. Unfortunately, without normalization, it sees "ls"
from the cycler, and "linestyle" from the manual spec and doesn't know that
they are the same thing. The "ls" value then overrides the "linestyle"
value when setting the artist properties.
@tacaswell, we probably need to set a minimum version of cycler to depend
on so that I can write a patch that utilizes the "key_change()" feature I
added to cycler awhile back. Have you released a version with that feature?
This might be the normalization bug we are seeing elsewhere. I have code
that normalizes the key names from 'ls' to 'linestyle', but it seems to
only trigger for cycles defined from the rc file. If a cycle object is
passed in, it just uses it as-is. Unfortunately, I needed that
normalization feature to simplify the cycle advancing feature. The
linestyle given by 'k:' is compared with the properties from the cycler.
Only properties from the cycler that doesn't exist in the manual
specification are taken. Unfortunately, without normalization, it sees "ls"
from the cycler, and "linestyle" from the manual spec and doesn't know that
they are the same thing. The "ls" value then overrides the "linestyle"
value when setting the artist properties.
@tacaswell, we probably need to set a minimum version of cycler to depend
on so that I can write a patch that utilizes the "key_change()" feature I
added to cycler awhile back. Have you released a version with that feature?
This might be the normalization bug we are seeing elsewhere. I have code
that normalizes the key names from 'ls' to 'linestyle', but it seems to
only trigger for cycles defined from the rc file. If a cycle object is
passed in, it just uses it as-is. Unfortunately, I needed that
normalization feature to simplify the cycle advancing feature. The
linestyle given by 'k:' is compared with the properties from the cycler.
Only properties from the cycler that doesn't exist in the manual
specification are taken. Unfortunately, without normalization, it sees
"ls"
from the cycler, and "linestyle" from the manual spec and doesn't know
that
they are the same thing. The "ls" value then overrides the "linestyle"
value when setting the artist properties.
Might also be worth considering monkey-patching cycler if it is missing the
change_key() method. I think all the relevant logic is contained within
that method, I'll have to double-check that PR.
@tacaswell, we probably need to set a minimum version of cycler to depend
on so that I can write a patch that utilizes the "key_change()" feature I
added to cycler awhile back. Have you released a version with that
feature?
This might be the normalization bug we are seeing elsewhere. I have
code
that normalizes the key names from 'ls' to 'linestyle', but it seems to
only trigger for cycles defined from the rc file. If a cycle object is
passed in, it just uses it as-is. Unfortunately, I needed that
normalization feature to simplify the cycle advancing feature. The
linestyle given by 'k:' is compared with the properties from the
cycler.
Only properties from the cycler that doesn't exist in the manual
specification are taken. Unfortunately, without normalization, it sees
"ls"
from the cycler, and "linestyle" from the manual spec and doesn't know
that
they are the same thing. The "ls" value then overrides the "linestyle"
value when setting the artist properties.
Activity
tacaswell commentedon Jan 18, 2016
Thanks for reporting this.
WeatherGod commentedon Jan 27, 2016
This might be the normalization bug we are seeing elsewhere. I have code
that normalizes the key names from 'ls' to 'linestyle', but it seems to
only trigger for cycles defined from the rc file. If a cycle object is
passed in, it just uses it as-is. Unfortunately, I needed that
normalization feature to simplify the cycle advancing feature. The
linestyle given by 'k:' is compared with the properties from the cycler.
Only properties from the cycler that doesn't exist in the manual
specification are taken. Unfortunately, without normalization, it sees "ls"
from the cycler, and "linestyle" from the manual spec and doesn't know that
they are the same thing. The "ls" value then overrides the "linestyle"
value when setting the artist properties.
On Mon, Jan 18, 2016 at 1:40 PM, Thomas A Caswell notifications@github.com
wrote:
WeatherGod commentedon Jan 27, 2016
@tacaswell, we probably need to set a minimum version of cycler to depend
on so that I can write a patch that utilizes the "key_change()" feature I
added to cycler awhile back. Have you released a version with that feature?
On Wed, Jan 27, 2016 at 5:32 PM, Benjamin Root ben.v.root@gmail.com wrote:
tacaswell commentedon Jan 27, 2016
No, we need to do new release of cycler.
On Wed, Jan 27, 2016 at 5:39 PM Benjamin Root notifications@github.com
wrote:
WeatherGod commentedon Jan 27, 2016
Might also be worth considering monkey-patching cycler if it is missing the
change_key() method. I think all the relevant logic is contained within
that method, I'll have to double-check that PR.
On Wed, Jan 27, 2016 at 5:46 PM, Thomas A Caswell notifications@github.com
wrote:
Improvements to property cycler. Closes matplotlib#5875
Improvements to property cycler. Closes #5875