histogram

How to add a legend to the multiple histograms with ggplot?

萝らか妹 提交于 2020-06-28 14:48:52
问题 I am trying to add a legend to the graph but it doesn't work. Do you have any ideas ? Here is my code : ggplot(data =stats_201507_AF ) + geom_histogram(aes(gross_ind),fill="dodgerblue3", show.legend =T,bins=25)+ geom_histogram(aes(net_ind),fill="springgreen4",show.legend = T,bins=25) + geom_histogram(aes(tax_ind),fill="gold2",show.legend = T, bins=25) + xlab("Indices")+ scale_colour_manual(values=c("dodgerblue3","springgreen4","gold2")) I wanted a description for every histogram with a

Gnuplot color every nth box in histogram

和自甴很熟 提交于 2020-06-27 17:36:25
问题 I am plotting a large number of bars and therefore I only mark the every nth xtic (as seen in the .dat file with " "). Here are the first 15 lines of my input ".dat" file: 1 150 " " 260 " " 340 " " 410 5 270 " " 280 " " 260 " " 370 " " 220 10 230 " " 340 " " 300 " " 200 " " 240 15 160 Plotting this data works fine. However, in my actual .dat file I have about 500k values to plot (500k boxes). Therefore I wanted to color every 10k box with a certain color (or in the example above, every 5th).

r percentage by bin in histogram ggplot

房东的猫 提交于 2020-06-26 06:19:20
问题 I have a data set like this -> library(ggplot2) response <- c("Yes","No") gend <- c("Female","Male") purchase <- sample(response, 20, replace = TRUE) gender <- sample(gend, 20, replace = TRUE) df <- as.data.frame(purchase) df <- cbind(df,gender) so head(df) looks like this -> purchase gender 1 Yes Female 2 No Male 3 No Female 4 No Female 5 Yes Female 6 No Female Also, so you can validate my examples, here is table(df) for my particular sampling. (please don't worry about matching my

Histogram update in a for loop with matplotlib.pylab

走远了吗. 提交于 2020-06-14 07:53:45
问题 I am trying to update in for loop a histogram data. but I don't know how to make it. I tried with set_data but it is not working. here is the code: plt.ion() ax=plt.subplot(111) [n,X, V]=ax.hist(range(MAX_X),bins=33,normed=True) .... alternative=defaultdict(list) ... for z in range(0,max(alternative)): stat=zeros(33,int) for i in range(len(alternative[z])): stat[alternative[z][i]]+=1 [n,X, V].set_data(stat)// problem here!!!!!!! plt.draw() 回答1: So the problem comes from the fact that [n,X,V]

how to generate a series of histograms on matplotlib?

限于喜欢 提交于 2020-06-08 20:01:30
问题 I would like to generate a series of histogram shown below: The above visualization was done in tensorflow but I'd like to reproduce the same visualization on matplotlib. EDIT: Using plt.fill_between suggested by @SpghttCd, I have the following code: colors=cm.OrRd_r(np.linspace(.2, .6, 10)) plt.figure() x = np.arange(100) for i in range(10): y = np.random.rand(100) plt.fill_between(x, y + 10-i, 10-i, facecolor=colors[i] edgecolor='w') plt.show() This works great, but is it possible to use

how to generate a series of histograms on matplotlib?

[亡魂溺海] 提交于 2020-06-08 20:00:41
问题 I would like to generate a series of histogram shown below: The above visualization was done in tensorflow but I'd like to reproduce the same visualization on matplotlib. EDIT: Using plt.fill_between suggested by @SpghttCd, I have the following code: colors=cm.OrRd_r(np.linspace(.2, .6, 10)) plt.figure() x = np.arange(100) for i in range(10): y = np.random.rand(100) plt.fill_between(x, y + 10-i, 10-i, facecolor=colors[i] edgecolor='w') plt.show() This works great, but is it possible to use

Histogram with different colours using the abline function in R

和自甴很熟 提交于 2020-05-28 08:38:30
问题 I would like to plot a histogram with different colours and legend. Assuming the following data: df1<- rnorm(300,60,5) I have used the following codes to get the histogram plot and the lines using the abline function: df1<-data.frame(df1) attach(df1) hist(M,at=seq(0,100, 2)) abline(v=80, col="blue") abline(v=77, col="red") abline(v=71, col="red") abline(v=68, col="blue") abline(v=63, col="blue") abline(v=58, col="blue") abline(v=54, col="blue") abline(v=51, col="blue") abline(v=457, col="blue

Histogram with different colours using the abline function in R

…衆ロ難τιáo~ 提交于 2020-05-28 08:38:13
问题 I would like to plot a histogram with different colours and legend. Assuming the following data: df1<- rnorm(300,60,5) I have used the following codes to get the histogram plot and the lines using the abline function: df1<-data.frame(df1) attach(df1) hist(M,at=seq(0,100, 2)) abline(v=80, col="blue") abline(v=77, col="red") abline(v=71, col="red") abline(v=68, col="blue") abline(v=63, col="blue") abline(v=58, col="blue") abline(v=54, col="blue") abline(v=51, col="blue") abline(v=457, col="blue

Histogram with different colours using the abline function in R

狂风中的少年 提交于 2020-05-28 08:38:09
问题 I would like to plot a histogram with different colours and legend. Assuming the following data: df1<- rnorm(300,60,5) I have used the following codes to get the histogram plot and the lines using the abline function: df1<-data.frame(df1) attach(df1) hist(M,at=seq(0,100, 2)) abline(v=80, col="blue") abline(v=77, col="red") abline(v=71, col="red") abline(v=68, col="blue") abline(v=63, col="blue") abline(v=58, col="blue") abline(v=54, col="blue") abline(v=51, col="blue") abline(v=457, col="blue

Histogram with different colours using the abline function in R

独自空忆成欢 提交于 2020-05-28 08:37:21
问题 I would like to plot a histogram with different colours and legend. Assuming the following data: df1<- rnorm(300,60,5) I have used the following codes to get the histogram plot and the lines using the abline function: df1<-data.frame(df1) attach(df1) hist(M,at=seq(0,100, 2)) abline(v=80, col="blue") abline(v=77, col="red") abline(v=71, col="red") abline(v=68, col="blue") abline(v=63, col="blue") abline(v=58, col="blue") abline(v=54, col="blue") abline(v=51, col="blue") abline(v=457, col="blue