ppinard / matplotlib-colorbar Goto Github PK
View Code? Open in Web Editor NEWProvides a new artist for matplotlib to display a colorbar
License: BSD 2-Clause "Simplified" License
Provides a new artist for matplotlib to display a colorbar
License: BSD 2-Clause "Simplified" License
When importing from matplotlib_colorbar.colorbar import Colorbar
after matplotlib has already been imported, say with %matplotlib inline
, a warning comes up:
/Users/username/anaconda3/envs/scipy/lib/python3.6/site-packages/ipykernel/__main__.py:8: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
I managed to trace the warning, and it's coming from matplotlib_colorbar/colorbar.py
, line 83:
imp.reload(sys.modules['matplotlib'])
If this is OK, maybe you can suppress the warning?
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore", UserWarning)
imp.reload(sys.modules['matplotlib'])
The scale of the drawn colorbar is not independent of the data scale.
The following code generates the following image
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
from matplotlib_colorbar.colorbar import Colorbar
%matplotlib inline
data = np.array(plt.imread(cbook.get_sample_data('grace_hopper.png')))
mappable = plt.imshow(data[...,0], cmap='viridis')
colorbar = Colorbar(mappable, location='lower left')
plt.gca().add_artist(colorbar)
Modifying the data scale (by multiplying by 15) with the following code generates this image
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
from matplotlib_colorbar.colorbar import Colorbar
%matplotlib inline
data = np.array(plt.imread(cbook.get_sample_data('grace_hopper.png')))
mappable = plt.imshow(data[...,0]*15, cmap='viridis')
colorbar = Colorbar(mappable, location='lower left')
plt.gca().add_artist(colorbar)
It seems that the colorbar is not providing norm
to the PatchCollection
, resulting in the wrong colors being plotted.
The following error occurs when travis tries to upload new release to PyPi:
HTTPError: 401 Client Error: You must be identified to edit package information for url: https://pypi.python.org/pypi
When the colorbar is rather small the ticks along the colorbar are merging with each other and are not
recognizable anymore.
Traceback (most recent call last):
File "plot_this.py", line 6, in <module>
from matplotlib_colorbar.colorbar import Colorbar
File "/usr/lib/python3.7/site-packages/matplotlib_colorbar/colorbar.py", line 41, in <module>
from matplotlib.cbook import is_string_like
ImportError: cannot import name 'is_string_like' from 'matplotlib.cbook' (/usr/lib/python3.7/site-packages/matplotlib/cbook/__init__.py)
System info:
Python 3.7.0 (default, Sep 15 2018, 19:13:07)
[GCC 8.2.1 20180831] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib as mlab
>>> mlab.__version__
'3.0.0'
>>> import matplotlib_colorbar as mcb
>>> mcb.__version__
'0.3.5'
>>> from matplotlib_colorbar.colorbar import Colorbar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.7/site-packages/matplotlib_colorbar/colorbar.py", line 41, in <module>
from matplotlib.cbook import is_string_like
ImportError: cannot import name 'is_string_like' from 'matplotlib.cbook' (/usr/lib/python3.7/site-packages/matplotlib/cbook/__init__.py)
>>>
See issue ppinard/matplotlib-scalebar#3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.