Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logarithmic density estimate #31

Open
KevinAquino opened this issue May 31, 2019 · 5 comments
Open

logarithmic density estimate #31

KevinAquino opened this issue May 31, 2019 · 5 comments

Comments

@KevinAquino
Copy link

KevinAquino commented May 31, 2019

Hi all,

First off, love the repo!

Secondly, I was wondering what types of features can help with visualising the tails of distributions? I currently have three datasets with different tails, the "drops" do a nice job of visualising the tails, but I feel like the default density estimate is lacking in that regard - I would typically analyse the density estimate with a logarithmic scaling (see second plot)

Are there features in the pipeline to deal with this (now or in the future)? It makes the raincloud plot a little different, but maybe this has been thought of already?

image

image

@pog87
Copy link
Member

pog87 commented May 31, 2019

Hi Kevin.

Thanks for writing us!
Did you try to change the bw input argument?

@KevinAquino
Copy link
Author

Hiya Davide,

I'm using the Matlab implementation so I assume you mean changing the band_width of the KSD estimate? I tried changing this but the density plots seem to converge at the tails. The KSD estimate is not too bad but visually I think a logarithmic y-axis would useful to add to the standard raincloud plot - although it would be a log-rain-cloud plot.

The distinction could be made clear if there was a y-axis displayed so one knows if we have a logarithmic or a standard rain-cloud plot, below is an example of a "log-rain-cloud" plot

image

@pog87
Copy link
Member

pog87 commented Jun 3, 2019

I see your point, this is a choice one user could look for, as in the case of log-histograms. Can you show some code you used to make the logCloud?

@micahgallen
Copy link
Member

micahgallen commented Jun 3, 2019 via email

@KevinAquino
Copy link
Author

KevinAquino commented Jun 25, 2019

Sorry for the delay, was writing this just before a conference!

Here is a section of code I hacked together rather quickly to do this: This is clunky 🙈 and fit for my purpose in Matlab. It is tricky to get the logarithmic axes working so the box plot with the rain drops need to be made in a different axis to the cloud.

In action its in a latest ms I've submitted : https://www.biorxiv.org/content/10.1101/662726v1 figure 12

% Generate some synthetic data:
data{1} = randn(1000,1);
data{2} = randn(1000,1);
data{3} = randn(1000,1).^3;



figure('color','white');
ax1 =subplot(211);
% Generate some colors for the mapping
theColors{1} = [0 0 1];
theColors{2} = [0 1 1];
theColors{3} = [1 0 1];
% Label these data
labels={'one','two','three'}

% Make generic Raincloud plots
h1 = raincloud_plot(data{1}, 'box_on', 1, 'color', theColors{1}, 'alpha', 0.5,...
     'box_dodge', 1, 'box_dodge_amount', .15, 'dot_dodge_amount', .15,...
     'box_col_match', 0);

h2 = raincloud_plot(data{2}, 'box_on', 1, 'color', theColors{2}, 'alpha', 0.5,...
     'box_dodge', 1, 'box_dodge_amount', .35, 'dot_dodge_amount', .35, 'box_col_match', 0);

h3 = raincloud_plot(data{3}, 'box_on', 1, 'color', theColors{3}, 'alpha', 0.5,...
     'box_dodge', 1, 'box_dodge_amount', .55, 'dot_dodge_amount', .55, 'box_col_match', 0);

% Turn off the box plots
for pl=2:6
	set(h1{pl},'visible','off');
	set(h2{pl},'visible','off');
	set(h3{pl},'visible','off');
end

set(gca,'fontSize',18,'Ylim',[1e-8 1],'XLim',[-5 10],'YScale','log','XTick',[]);
ylabel('Density');

ax2=subplot(212);

% replicate the rain cloud plots
h1rd = raincloud_plot(data{1}, 'box_on', 1, 'color', theColors{1}, 'alpha', 0.5,...
     'box_dodge', 1, 'box_dodge_amount', .15, 'dot_dodge_amount', .15,...
     'box_col_match', 0);

h2rd = raincloud_plot(data{2}, 'box_on', 1, 'color', theColors{2}, 'alpha', 0.5,...
     'box_dodge', 1, 'box_dodge_amount', .35, 'dot_dodge_amount', .35, 'box_col_match', 0);

h3rd = raincloud_plot(data{3}, 'box_on', 1, 'color', theColors{3}, 'alpha', 0.5,...
     'box_dodge', 1, 'box_dodge_amount', .55, 'dot_dodge_amount', .55, 'box_col_match', 0);

ylabel('Box plots');
set(gca,'YLim', [-0.35 0],'XLim',[-5 max(data{3}(:))*1.1],'fontSize',18,'YTick',[]);

% Turn off the clouds!

set(h1rd{1},'visible','off');
set(h2rd{1},'visible','off');
set(h3rd{1},'visible','off');

legend([h1{1} h2{1} h3{1}], labels);

ax1.OuterPosition = [0 0.45 1 0.5];
ax2.OuterPosition = [0 0 1 0.5];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants