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
ENH: Set the alpha value for plots in rcParams #5132
Can i set the "axes.color_cycle" values in hex natation as e.g.:
"#ff0000b4"
Because when i try to do so i receive an exception of "invalid hex color string"
take out the pound sign because our rcfile reader is really naive and
always treats that as a comment symbol.
Also note that color_cycle is deprecated in the upcoming 1.5 release,
replaced with the more versatile "prop_cycle" mechanism. However, it will
likely be awhile before we actually remove "color_cycle".
Can i set the "axes.color_cycle" values in hex natation as e.g.:
"#ff0000b4"
Because when i try to do so i receive an exception of "invalid hex color
string"
—
Reply to this email directly or view it on GitHub #5132 (comment)
.
Without the pound sign i get a "to_rgb: Invalid rgb arg "ff0000b4"" error.
The exact call is:
plt.rcParams['axes.color_cycle'][0] = "ff0000b4"
matplotlib version 1.4.3
Without the alpha content ("b4") it works fine. It seams to me that the parser doese not accept 4 Byte hex color codes with alpha content. I could work around this by using the to_rgba builtin method
My workaround looks as follows:
to_rgba = matplotlib.colors.ColorConverter().to_rgba
for i, c in enumerate(plt.rcParams['axes.color_cycle']):
plt.rcParams['axes.color_cycle'][i] = to_rgba(c,0.2)
Without the pound sign i get a "to_rgb: Invalid rgb arg "ff0000b4"" error.
The exact call is:
plt.rcParams['axes.color_cycle'][0] = "ff0000b4"
matplotlib version 1.4.3
Without the alpha content ("b4") it works fine. It seams to me that the
parser doese not accept 4 Byte hex color codes with alpha content. I could
work around this by using the to_rgba builtin method
My working code looks as follows:
to_rgba = matplotlib.colors.ColorConverter().to_rgba
for i, c in enumerate(plt.rcParams['axes.color_cycle']):
plt.rcParams['axes.color_cycle'][i] = to_rgba(c,0.2)
—
Reply to this email directly or view it on GitHub #5132 (comment)
.
Yes rcparams takes a 4-tuple as an input. As @WeatherGod stated the problem was related to the fact that the color parser only checks for 3-Byte (#FFFFFF) color strings and does not understand 4-Byte (#FFFFFFAA) color strings with alpha channel. So the way i presented the color information was not suiteable to the parser
I frequently need alpha independently of the color cycler. Most importantly I want different plots to have different default alphas, f.i. alpha=.5 for my scatter plots, while not using alpha for my line plots. Thus, as far as I can see, setting alpha to the color cycle is not working. Any change this is going to be implemented in the rcParams?
Activity
tacaswell commentedon Sep 24, 2015
You can do this by setting a the color/prop cycle to use colors which have an alpha component.
The traitlet overhaul will take care of this as well
Jul3k commentedon Sep 24, 2015
Can i set the "axes.color_cycle" values in hex natation as e.g.:
"#ff0000b4"
Because when i try to do so i receive an exception of "invalid hex color string"
WeatherGod commentedon Sep 24, 2015
take out the pound sign because our rcfile reader is really naive and
always treats that as a comment symbol.
Also note that color_cycle is deprecated in the upcoming 1.5 release,
replaced with the more versatile "prop_cycle" mechanism. However, it will
likely be awhile before we actually remove "color_cycle".
On Thu, Sep 24, 2015 at 9:30 AM, Jul3k [email protected] wrote:
Jul3k commentedon Sep 24, 2015
Without the pound sign i get a "to_rgb: Invalid rgb arg "ff0000b4"" error.
The exact call is:
matplotlib version 1.4.3
Without the alpha content ("b4") it works fine. It seams to me that the parser doese not accept 4 Byte hex color codes with alpha content. I could work around this by using the to_rgba builtin method
My workaround looks as follows:
WeatherGod commentedon Sep 24, 2015
Ah, indeed, our hex color spec parser is just rgb, not rgb[a]. Sounds like
an easy feature to implement, though...
On Thu, Sep 24, 2015 at 10:21 AM, Jul3k [email protected] wrote:
tacaswell commentedon Sep 24, 2015
Pretty sure rcparams will take a 4-tuple an input
Jul3k commentedon Sep 24, 2015
Yes rcparams takes a 4-tuple as an input. As @WeatherGod stated the problem was related to the fact that the color parser only checks for 3-Byte (#FFFFFF) color strings and does not understand 4-Byte (#FFFFFFAA) color strings with alpha channel. So the way i presented the color information was not suiteable to the parser
tacaswell commentedon Sep 24, 2015
@Jul3k Can you make a new issue to upgrade out hex parser to deal with RGBA hex codes?
Jul3k commentedon Sep 24, 2015
I opend a new issue relating to the color spec parser
WeatherGod commentedon May 19, 2016
I think this is closed by #6382, which updated the parser to allow 4-byte hex strings. Re-open this issue if that isn't sufficient.
JoElfner commentedon Aug 6, 2020
I frequently need
alphaindependently of the color cycler. Most importantly I want different plots to have different default alphas, f.i.alpha=.5for my scatter plots, while not using alpha for my line plots. Thus, as far as I can see, setting alpha to the color cycle is not working. Any change this is going to be implemented in thercParams?timhoffm commentedon Aug 6, 2020
This is too specialized for
rcParams, in particular if you want to have different values for scatter plots and line plots.