Working in IJulia. Desperately trying to make a custom colormap. Tried the line:
matplotlib.colors.ListedColormap([(1,0,0),(0,1,0),(0,0,1)],"A")
which resulted in the following error
type PyObject has no field colors while loading In[16], in expression starting on line 1
which apparently means that I cannot use matplotlib directly, but only the functions which are in PyPlot.
I cannot involve matplotlib with an import (as this is invalid in IJulia). I have noted that others have had help on similar problems, but that doesn't solve mine.
The new default colormap used by matplotlib. cm. ScalarMappable instances is 'viridis' (aka option D).
if you have RGB colors, go to http://www.rgbtohex.net/ and convert the rgb colors to hex numbers. In seaborn, we have a function called color_pallet and we can pass our list of colors to it and your colors will be applied to your graphs. Now, just simply plot your graph with your own custom colors. Happy plotting!
By using the PyCall package which PyPlot is using to wrap matplotlib you can obtain a colormap like this:
using PyCall
@pyimport matplotlib.colors as matcolors
cmap = matcolors.ListedColormap([(1,0,0),(0,1,0),(0,0,1)],"A")
In order to access fields in a PyObject you need to index the object with a symbol like:
cmap[:set_over]((0,0,0))
This is equivalent to: cmap.set_over((0,0,0))
in python. For other good examples of how to plot different kinds of plots using PyPlot, see these examples: https://gist.github.com/gizmaa/7214002
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With