tkf / fillplots

Library to plot regions and boundaries given inequalities
BSD 2-Clause "Simplified" License
6 stars 2 forks source link

KeyError: 'axes.color_cycle' #3

Open ghost opened 3 years ago

ghost commented 3 years ago
from fillplots import plot_regions
plotter = plot_regions([
    [(lambda x: x ** 2,),  # x ^ 2 > 0 and
     (lambda x: x + 5,)],  # x + 5 > 0
])

KeyError Traceback (most recent call last)

in 2 plotter = plot_regions([ 3 [(lambda x: x ** 2,), # x ^ 2 > 0 and ----> 4 (lambda x: x + 5,)], # x + 5 > 0 5 ]) ~/development/python_env/NeuralShieldEnv/lib/python3.7/site-packages/fillplots/api.py in plot_regions(regions, *args, **kwds) 150 'Passing ax to plot functions is not implemented') 151 plotkwds['ax'] = kwds.pop('ax') --> 152 plotter = Plotter(regions, *args, **kwds) 153 plotter.plot(**plotkwds) 154 return plotter ~/development/python_env/NeuralShieldEnv/lib/python3.7/site-packages/fillplots/api.py in __init__(self, regions, config, xlim, ylim) 123 def __init__(self, regions, config='default', 124 xlim=(-10, 10), ylim=(-10, 10)): --> 125 config = get_config(config) or config 126 super(Plotter, self).__init__(config, regions) 127 self.config.xlim = xlim ~/development/python_env/NeuralShieldEnv/lib/python3.7/site-packages/fillplots/api.py in get_config(name) 13 def get_config(name): 14 if name in styles: ---> 15 return Config(**styles[name]) 16 17 ~/development/python_env/NeuralShieldEnv/lib/python3.7/site-packages/fillplots/core.py in __init__(self, *args, **kwds) 90 if not hasattr(self, 'fill_color_cycle'): 91 from .mplcolors import fill_color_list ---> 92 self.fill_color_cycle = itertools.cycle(fill_color_list()) 93 # FIXME: this does not work when initialized before the base 94 # config (and then base config is set afterwards). ~/development/python_env/NeuralShieldEnv/lib/python3.7/site-packages/fillplots/mplcolors.py in fill_color_list(alpha, colors, bg) 9 def fill_color_list(alpha=0.5, colors=None, bg=(1, 1, 1)): 10 if colors is None: ---> 11 colors = rcParams['axes.color_cycle'] 12 rgbs = map(colorConverter.to_rgb, colors) 13 return [alpha_compositing(fg, bg, alpha) for fg in rgbs] ~/development/python_env/NeuralShieldEnv/lib/python3.7/site-packages/matplotlib/__init__.py in __getitem__(self, key) 832 plt.switch_backend(rcsetup._auto_backend_sentinel) 833 --> 834 return dict.__getitem__(self, key) 835 836 def __repr__(self): KeyError: 'axes.color_cycle' My environment: ```shell absl-py==0.9.0 aiohttp==3.6.2 aiohttp-cors==0.7.0 aioredis==1.3.1 argon2-cffi==20.1.0 astor==0.8.1 astunparse==1.6.3 async-timeout==3.0.1 atari-py==0.2.6 attrs==19.3.0 backcall==0.1.0 beautifulsoup4==4.9.1 bleach==3.1.5 blessings==1.7 cachetools==4.1.0 certifi==2020.4.5.1 cffi==1.14.2 chardet==3.0.4 click==7.1.2 cloudpickle==1.3.0 colorama==0.4.3 colorful==0.5.4 -e git+https://github.com/caffett/CoRec.git@2ce08448560e442790bd0159ddd6455cf75eb775#egg=CoRec cycler==0.10.0 decorator==4.4.2 defusedxml==0.6.0 entrypoints==0.3 filelock==3.0.12 fillplots==0.0.2 future==0.18.2 gast==0.3.3 google==2.0.3 google-api-core==1.24.0 google-auth==1.24.0 google-auth-oauthlib==0.4.1 google-pasta==0.2.0 googleapis-common-protos==1.52.0 gpustat==0.6.0 grpcio==1.29.0 gym==0.17.2 h5py==2.10.0 hiredis==1.1.0 idna==2.9 importlib-metadata==1.6.0 ipdb==0.13.2 ipykernel==5.3.4 ipython==7.14.0 ipython-genutils==0.2.0 jedi==0.17.0 Jinja2==2.11.2 joblib==0.15.1 json5==0.9.5 jsonschema==3.2.0 jupyter-client==6.1.6 jupyter-core==4.6.3 jupyterlab==2.2.5 jupyterlab-server==1.2.0 Keras-Applications==1.0.8 Keras-Preprocessing==1.1.2 kiwisolver==1.2.0 Markdown==3.2.2 MarkupSafe==1.1.1 matplotlib==3.2.1 mistune==0.8.4 mpi4py==3.0.3 msgpack==1.0.1 multidict==4.7.6 nbconvert==5.6.1 nbformat==5.0.7 networkx==2.5 # Editable install with no version control (neural-shield-zikang.xiong==0.0.1) -e /home/zikang/development/NeuralShield notebook==6.1.3 numpy==1.16.6 nvidia-ml-py3==7.352.0 oauthlib==3.1.0 opencensus==0.7.11 opencensus-context==0.1.2 opencv-python==4.2.0.34 opt-einsum==3.2.1 packaging==20.4 pandas==1.0.3 pandocfilters==1.4.2 parso==0.7.0 pexpect==4.8.0 pickleshare==0.7.5 Pillow==7.1.2 pkg-resources==0.0.0 prometheus-client==0.8.0 prompt-toolkit==3.0.5 protobuf==3.12.1 psutil==5.7.3 ptyprocess==0.6.0 py-spy==0.3.3 pyaml==20.4.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 -e git+https://github.com/caffett/bullet3.git@5be4e9cd7d2f0a7f9a5223ffa28d088a6542b0e7#egg=pybullet pycparser==2.20 pydot==1.4.1 pyglet==1.5.0 Pygments==2.6.1 pygraphviz==1.6 pyparsing==2.4.7 pyrsistent==0.16.0 python-dateutil==2.8.1 pytz==2020.1 PyYAML==5.3.1 pyzmq==19.0.2 ray==1.0.1.post1 redis==3.4.1 requests==2.23.0 requests-oauthlib==1.3.0 rsa==4.0 scikit-learn==0.23.1 scikit-optimize==0.7.4 scipy==1.4.1 seaborn==0.11.1 Send2Trash==1.5.0 six==1.15.0 sklearn==0.0 soupsieve==2.0.1 -e git+https://github.com/hill-a/stable-baselines.git@98e9ee97302ee2eb53f3210acdea7ebe00eaefef#egg=stable_baselines tensorboard==1.14.0 tensorboard-plugin-wit==1.6.0.post3 tensorflow==1.14.0 tensorflow-estimator==1.14.0 termcolor==1.1.0 terminado==0.8.3 testpath==0.4.4 tflearn==0.3.2 threadpoolctl==2.0.0 torch==1.5.0 tornado==6.0.4 traitlets==4.3.3 urllib3==1.25.9 wcwidth==0.1.9 webencodings==0.5.1 Werkzeug==1.0.1 wrapt==1.12.1 yagmail==0.11.224 yarl==1.4.2 zipp==3.1.0 ```
YestinYang commented 3 years ago

Since axes.color_cycle deprecated in matplotlib 2.2.0, you can edit Line 13 in mplcolors.py to colors = rcParams['axes.prop_cycle'].by_key()['color'], and it works fine for me.

The path of this file should be as below: <your_python_path>/lib/<python_version>/site-packages/fillplots/mplcolors.py for example in my Mac: ~/py/lib/python3.7/site-packages/fillplots/mplcolors.py