mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.58k stars 1.93k forks source link

transparency #208

Closed razcore-rad closed 10 years ago

razcore-rad commented 10 years ago

Hi again... I just wanted to add that I'm finding that the only functionality in terms of plotting is passing an alpha value around. For example I'm trying to plot 4 things on the same graph using factorplot with kind='point' and I'm finding not having a way to add transparency is... well, not nice :).

s01

In the above image there are 4 colors, but you can barely see the red there under the violet (it's more visible to the right). So I'm forced to do something like

fg = sns.factorplot(...)
for ax in fg.axes.flat:
    [i.set_alpha(.75) for i in ax.collections]
    [i.set_alpha(.75) for i in ax.lines]

Note that I can do this because I'm not plotting any errors bars... if I were I wouldn't be able to pick the right lines to apply the transparency to... What do you think? :) is it reasonable?...

mwaskom commented 10 years ago

It should be easier to get keyword arguments down to the points and lines, although in this case it looks like the red and purple are so overlapping that if you added alpha they would just mix to look like a single reddish-purplish line.

Maybe try faceting this variable on rows?

razcore-rad commented 10 years ago

Yes I know that in this particular case is like this... but, I was thinking about it in general. I'm missing this functionality because I was using it with matplotlib alone quite regularly... The picture above is just something I had around and wanted to make the point with :)...

mwaskom commented 10 years ago

Yeah I agree it would be useful, it's just a bit tricky because the same set of keyword args can't control both the points and the lines (because the points are actually down with scatter to get better size control), so exposing full control leads to a messy interface. But it's something that's on my agenda.

razcore-rad commented 10 years ago

Well, I don't know the internals that well, but why not just have a markers_kw and lines_kw instead (of markers, linestyles)? to be passed to the corresponding plot functions for individual styling...?

mwaskom commented 10 years ago

You'd want to use different alpha values for different levels of the hue variable? That's primarily what the markers and linestyles options are for (although you can also use them to apply one style across all levels. Handling dicts of kws for each hue variable seems very complicated.

razcore-rad commented 10 years ago

Well, no. I'd imagine someone wanting to plot all things with the same alpha value, although I could see the merit in having different alphas for markers vs. lines. When I get the chance I'll dig in the code and see if there's some reasonable way of doing it :).

Răzvan

Răzvan-Cosmin RĂDULESCU

Centre for Climate & Air Pollution Studies (C-CAPS) Department of Physics National University of Ireland, Galway, Ireland Mobile: +353 85-7848259 email: razvan.radulescu@nuigalway.ie

2014-05-28 16:59 GMT+01:00 Michael Waskom notifications@github.com:

You'd want to use different alpha values for different levels of the huevariable? That's primarily what the markers and linestyles options are for (although you can also use them to apply one style across all levels. Handling dicts of kws for each hue variable seems very complicated.

— Reply to this email directly or view it on GitHubhttps://github.com/mwaskom/seaborn/issues/208#issuecomment-44427356 .

mwaskom commented 10 years ago

Ah yeah the main idea for those parameters is to do something like this:

tips = sns.load_dataset("tips")
sns.factorplot("size", "total_bill", hue="sex", data=tips,
               ci=None, linestyles=["-", "--"], kind="point")

factorplot

not to generally set the aesthetic details, so I wouldn't want to overload those particular parameters any further.

razcore-rad commented 10 years ago

I wanted to know if I'm missing something obvious about the transparency. I know how to use the styles thanks :).

But since the alpha thing is on your todo list I'll live it at that. I'll browse the code and see if I can spot a way of integrating it in a "clever" way. Thanks for your time.

Răzvan

Răzvan-Cosmin RĂDULESCU

Centre for Climate & Air Pollution Studies (C-CAPS) Department of Physics National University of Ireland, Galway, Ireland Mobile: +353 85-7848259 email: razvan.radulescu@nuigalway.ie

2014-05-28 17:05 GMT+01:00 Michael Waskom notifications@github.com:

Ah yeah the main idea for those parameters is to do something like this:

tips = sns.load_dataset("tips")sns.factorplot("size", "total_bill", hue="sex", data=tips, ci=None, linestyles=["-", "--"], kind="point")

[image: factorplot]https://cloud.githubusercontent.com/assets/315810/3107088/d7364ad2-e681-11e3-9178-7fe1825d8789.png

not to generally set the aesthetic details, so I wouldn't want to overload those particular parameters any further.

— Reply to this email directly or view it on GitHubhttps://github.com/mwaskom/seaborn/issues/208#issuecomment-44428423 .