Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Pass rc.cmap and rc.cycle arguments through respective constructor functions #169

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

Closed
zxdawn opened this issue May 16, 2020 · 2 comments
Closed
Milestone

Comments

@zxdawn
Copy link

zxdawn commented May 16, 2020

Description

Since cycle supports cmaps, the input of cmap name in the configuration should be supported.

Steps to reproduce

import proplot as plot
import numpy as np

fig, axs = plot.subplots()
state = np.random.RandomState(51423)
data = (20 * state.rand(10, 21) - 10).cumsum(axis=0)

plot.rc.update({'cycle': 'plum', 'lines.linewidth': '5'})
lines = axs.plot(data[:, :5])

Expected behavior:
Like:

plot.rc.update({'lines.linewidth': '5'})
lines = axs.plot(data[:, :5], cycle='plum')

cmap

Actual behavior: [What actually happened]

Traceback (most recent call last):
  File "/home/xin/Desktop/test.py", line 11, in <module>
    plot.rc.update({'cycle': 'plum', 'lines.linewidth': '5'})
  File "/home/xin/Documents/Github/proplot/proplot/config.py", line 906, in update
    self.__setitem__(prefix + key, value)
  File "/home/xin/Documents/Github/proplot/proplot/config.py", line 410, in __setitem__
    kw_quick, kw_added, kw_params = self._get_param_dicts(key, value)
  File "/home/xin/Documents/Github/proplot/proplot/config.py", line 490, in _get_param_dicts
    colors = _get_cycle_colors(value)
  File "/home/xin/Documents/Github/proplot/proplot/config.py", line 1020, in _get_cycle_colors
    + ', '.join(map(repr, cycles)) + '.'
ValueError: Invalid cycle name 'plum'. Options are: '538', 'accent', 'classic', 'colorblind', 'colorblind10', 'dark2', 'default', 'flatui', 'ggplot', 'paired', 'pastel1', 'pastel2', 'qual1', 'qual2', 'set1', 'set2', 'set3', 'tab10', 'tab20', 'tab20b', 'tab20c'.

Proplot version

master branch

@lukelbd lukelbd changed the title cmap name doesn't work in the configuration of cycle Pass rc.cmap and rc.cycle arguments through respective constructor functions May 19, 2020
@lukelbd lukelbd added this to the Version 0.8 milestone Jul 21, 2021
@lukelbd
Copy link
Collaborator

lukelbd commented Jul 30, 2021

I'm going to close this as a duplicate of #69. When I add rc-param assignment validation it will be trivial to pass assignments to rc.cmap and rc.cycle through the Colormap and Cycle constructors.

@lukelbd
Copy link
Collaborator

lukelbd commented Aug 18, 2021

Now that rc settings are validated, this has been implemented. It works by saving the colormap name to the rc dict (necessary since the rc dicts should only contain settings printable to proplotrc files). For example:

pplt.rc.cmap = pplt.Colormap('magma')
print(pplt.rc.cmap)

returns 'magma' rather than a colormap instance. This is ok since colormaps assigned to these settings are also automatically registered.

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

2 participants