boxplot

Matlab boxplot properties

僤鯓⒐⒋嵵緔 提交于 2019-12-24 00:39:51
问题 I'm trying to plot this box plot like this: I tried this code: boxplot(randn(10,98)','notch','on') set(0,'DefaultAxesFontName', 'Cambria Math') ylabel('Normalized Parameter'); set(gca,'FontSize',14,'fontWeight','bold'); set(gca,'TickLabelInterpreter','tex'); set(gca,'XTickLabel',{'a_{0}','a_{1}','a_{2}','a_{3}','a_{4}','b_{1}','b_{2}','b_{3}','b_{4}','w'}) color = 'b'; h = findobj(gca,'Tag','Box'); for j=1:length(h) patch(get(h(j),'XData'),get(h(j),'YData'),color,'FaceAlpha',1); end lines =

matplotlib: box plot for each category

帅比萌擦擦* 提交于 2019-12-24 00:17:32
问题 My pandas data frame has two columns: category and duration . And I use the following code to make a box plot of all data points. import matplotlib.pyplot as plt plt.boxplot(df.duration) plt.show() However, if I want one box fore each category , how do I modify the above code? Thanks! 回答1: We can do it with pandas #df=pd.DataFrame({'category':list('aacde'),'duration':[1,3,2,3,4]}) sample data df.assign(index=df.groupby('category').cumcount()).pivot('index','category','duration').plot(kind=

R: why is boxplot(x,log=“y”) different from boxplot(log(x))?

坚强是说给别人听的谎言 提交于 2019-12-23 19:59:23
问题 delme <- exp(rnorm(1000,1.5,0.3)) boxplot(delme,log="y") boxplot(log10(delme)) Why are the whiskers different in this 2 plots? Thanks Agus 回答1: I would say that in your first plot you just changed the y axis to log, so the values you plot still range between 1 and 10. In this plot the y axis is a log scale. The whiskers on this axis look different because the space between each "tick" (ie axis break) is not constant (there is more space between 2 and 4 than between 10 and 8) In the second

How do I sort a dataframe by the average of subsets of one of the rows?

拟墨画扇 提交于 2019-12-23 16:55:49
问题 I'm fairly new to R, but I'm making good progress. I've been able to bend ggplot2 to my will with the exception of one thing: the order that the categorical labels are plotted along the x axis in my boxplot. I think this is just a hole in my knowledge of how to address ranges of a dataframe in formulas, but here's the fake data, as a dataframe called df: Index Label Value index1 A 1 index2 A 2 index3 A 3 index4 B 12 index5 B 11 index6 B 10 index7 C 8 index8 C 7 index9 C 9 ... index76 Z 15

How to widen boxes in Seaborn boxplot?

爷,独闯天下 提交于 2019-12-23 13:07:08
问题 I'm trying to make a grouped boxplot using Seaborn (Reference), and the boxes are all incredibly narrow -- too narrow to see the grouping colors. g = seaborn.factorplot("project_code",y="num_mutations",hue="organ", data=grouped_donor, kind="box", aspect=3) If I zoom in, or stretch the graphic several times the width of my screen, I can see the boxes, but obviously this isn't useful as a standard graphic. This appears to be a function of my amount of data; if I plot only the first 500 points

ggplot2 boxplot stat_summary text placement by group

…衆ロ難τιáo~ 提交于 2019-12-23 03:07:05
问题 In the plot below, I'd like the number of observations (40 in this case) to be overlayed on top of each boxplot. My code below doesn't work when there's a fill aesthetic. The text need to be adjusted horizontally (1 left, 1 center, 1 right in this case) so that they properly overlay their corresponding boxplots. dt <- data.table( x = factor(rep(1:2, each=120)) , f = rep(letters[1:3], 40) , y = c(rnorm(120, 1:3), rnorm(120, 1:3*2)) ) table(dt$x, dt$f) +--------------+ | a b c | +--------------

How to make the jitter point centered using ggplot2?

别来无恙 提交于 2019-12-22 14:41:39
问题 I am trying to recreate a multiple dot plot like the figure below. https://www.dropbox.com/s/9jqguesqd5gdm99/jitter%20plot.png Both geom_dotplot and position_jitter in ggplot2 have been tried. But neither of these two commands could make it. The figure created by position_jitter is quite similar, but there are also some differences. The point created by position_jitter seems too scattered, compared to the figure mentioned above. This is the figure I could make so far. https://www.dropbox.com

How to make the jitter point centered using ggplot2?

只谈情不闲聊 提交于 2019-12-22 14:40:29
问题 I am trying to recreate a multiple dot plot like the figure below. https://www.dropbox.com/s/9jqguesqd5gdm99/jitter%20plot.png Both geom_dotplot and position_jitter in ggplot2 have been tried. But neither of these two commands could make it. The figure created by position_jitter is quite similar, but there are also some differences. The point created by position_jitter seems too scattered, compared to the figure mentioned above. This is the figure I could make so far. https://www.dropbox.com

full text label on Boxplot, with added mean point

时光怂恿深爱的人放手 提交于 2019-12-22 09:59:24
问题 Am trying to get text label similar to what this https://stats.stackexchange.com/questions/8206/labeling-boxplots-in-r, but I cant get it to work. MWE similar to what I have is this: data <- data.frame(replicate(5,sample(0:100,100,rep=TRUE))) meanFunction <- function(x){ return(data.frame(y=round(mean(x),2),label=round(mean(x,na.rm=T),2)))} ggplot(melt(data), aes(x=variable, y=value)) + geom_boxplot(aes(fill=variable), width = 0.7) + stat_summary(fun.y = mean, geom="point",colour="darkred",

How can I resize the boxes in a boxplot created with R and ggplot2 to account for different frequencies amongst different boxplots? [duplicate]

六月ゝ 毕业季﹏ 提交于 2019-12-22 08:42:02
问题 This question already has answers here : Is there an equivalent in ggplot to the varwidth option in plot? (2 answers) Closed 5 years ago . I have a boxplot that I made in R with ggplot2 analagous to the sample boxplot below. The problem is, for the values on the y axis (in this sample, the number of cylinders in the car) I have very different frequencies -- I may have included 2 8 cylinder cars, but 200 4 cylinder cars. Because of this, I'd like to be able to resize the boxplots (in this case