You are using a discrete scale with an integer vector. Transform it to a factor instead g = ggplot(data = d, aes(x = factor(number.of.NA,levels=as.character(seq(0,max.miss,1))))) + ...

python-3.x,matplotlib,histogram

with your data, cases = list(set(actions)) fig, ax = plt.subplots() ax.hist(map(lambda x: times[actions==x], cases), bins=np.arange(min(times), max(times) + binwidth, binwidth), histtype='bar', stacked=True, label=cases) ax.legend() plt.show() produces ...

python,pandas,group-by,histogram

I think you've got the right idea, more or less, and are simply being caught up on syntax. For example, we can use the divide-by-ten-multiply-by-ten trick to add a LagBin column, and then groupby-count on that: In [21]: Clean["LagBin"] = (Clean["TLag"]//10)*10 In [22]: Clean Out[22]: TLag LagBin 0 NaN NaN...

mysql,aggregate-functions,histogram

If you don't know your total val ranges, but you know you need buckets of 1000 in size, you can do this: SELECT COUNT(*) `count`, 1000*FLOOR(val/1000) `from`, 1000*FLOOR(val/1000)+999 `to` FROM r_data WHERE transaction_type = 'send' GROUP BY FLOOR(val/1000) The expression GROUP BY FLOOR(val/1000) does the trick of aggregating your values...

data <- structure(c(-0.447315711911355, 0.670646511357067, 0.28805337765816, 0.210323243582978, 0.558951367403988, 0.607248748494035, -1.16412611819213, 0.0915424491269807, 0.469191549286902, -0.619038988584179, -0.659390830669932, -0.924810741449363, -1.42269762267215, -0.13593956988495, -1.92882493234572, -1.27638233136087, 1.3816213467106, 0.365757310517179, -0.479538532782686, 0.70769126786196, -0.326429694012458, -1.01751602957572, 0.555459246627799, -0.355015029145993, -0.065915904785214, 0.576685372310354,...

EDIT after comment. Better? ggplot()+ geom_histogram(aes(x=x), binwidth = 0.05, color = "grey30", fill = "white")+ coord_cartesian(xlim = c(0, 0.405)) + theme_tufte() + labs(y = "Frequency") + annotate("text", x = 0.4, xend = 0.4, y = 0.01, yend = .99, colour = "red", label = "//", size =6) ...

Use a nested call to table. Here's an example using a variable from iris: > table(iris$Sepal.Width) 2 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4 4.1 4.2 4.4 1 3 4 3 8 5 9 14 10 26 11...

Question 1 What do $mids and $equidist mean: From the help file: mids: the n cell midpoints. equidist: logical, indicating if the distances between breaks are all the same. Q2: Yes, with h1=hist(c(1,1,2,3,4,5,5,1.5), breaks=0.5:5.5) 1.5 will fall into the 0.5-1.5 categorie. If you want it to fall into the 1.5-2.5...

You must give an explicit string as label: plot newhistogram 'foo', 'file.dat' u 2:xtic(1) t col, '' u 3 t col, \ '' u ($0-1):($2+$3):(sprintf('%.1f', $2+$3)) notitle w labels offset 0,1 font "Arial,8" As other improvement, I would use the offset option which allows you to give an displacement in...

Using IRanges, you should use findOverlaps or mergeByOverlaps instead of countOverlaps. It, by default, doesn't return no matches though. I'll leave that to you. Instead, will show an alternate method using foverlaps() from data.table package: require(data.table) subject <- data.table(interval = paste("int", 1:4, sep=""), start = c(2,10,12,25), end = c(7,14,18,28)) query...

python,image-processing,histogram

I doubt it is 3 histograms. It sounds more like you have a 3 dimensional array of 64x64x64 values of Y,Cb,Cr, where by each bucket (in that 3D array of buckets) is a count of how many people had that particular hair color. Normalizing is simply a matter of dividing...

1. Reaching 18. It appears that in your data you have at most 17 numbers in the category between 52.5 and 61.5. And that is even with open interval on both sides: sum(ages >= 52.5 & ages <= 61.5) [1] 17 So your histogram only reflects that. 2. Break symbol....

You can do it like this: value <- rnorm(300,mean=100,sd=20) nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,3)) par(mar=c(4,4,1,1)) boxplot(value, horizontal=TRUE, outline=TRUE,ylim=c(0,160), frame=F, col = "green1") hist(value,breaks=40,xlab="Runs",ylab="Runs frequency", main = "Score") ...

d = {'gender' : Series(['M', 'F', 'F', 'F', 'M']),'year' : Series([1900, 1910, 1920, 1920, 1920])} df = DataFrame(d) grouped = df.groupby('gender').year grouped.plot(kind='hist',legend=True) ...

hist actually takes vectors as input arguments, you wrote a matrix, so it just handles your input as if it was several vector-inputs. The output are the number of elements for each container (in your case 1:3, the second argument). [m,n] = hist([1,2,3;4,5,6;1,2,3],1:3) treats each column as one input. You...

Inspired by http://stackoverflow.com/a/30555229/635387 I came up with the following solution: import matplotlib.pyplot as plt import numpy as np d=[0.05, 0.1, 0.2, 1, 2, 3] def LogHistPlot(data, bins): totalWidth=0.8 colors=("b", "r", "g") for i, d in enumerate(data): heights = np.histogram(d, bins)[0] width=1/len(data)*totalWidth left=np.array(range(len(heights))) + i*width plt.bar(left, heights, width, color=colors[i], label=i) plt.xticks(range(len(bins)),...

c++,opencv,qt-creator,histogram

Preliminary: Did you notice you are not using at all your second version of the cumulative histogram function? void equalizeHist_16U(Mat* img, int x1, int x2, int y1, int y2) is calling compute_hist_16U(img, hist, true); and not: long compute_hist_16U (Mat* img, long* hist, bool cumul, int x1, int x2, int y1,...

Use histc instead of hist. histc allows you to define the edges while hist uses the second input parameter as centers.

Although you use xtic labels from your data file, the xtics are placed at integer x-values, starting at 0. Now, you cannot directly set arbitrary x-values when plotting histograms. You must use newhistogram at ... to shift the second part of the histogram further to the right: split = 8...

If I understood your question right, you want to histogram y's (or data(:,2)) that correspond to 10 bins of x (or data(:,1)). Please see the code below and refer to commented code and SO for further explanation on the code. % The following are custom-created to make the code self-contained,...

This is one way to solve this problem that leverages the hist() function for most of the heavy lifting, and has the advantage that the barplot of the cumulative sum of y matches the bins and dimensions of the histogram of x: set.seed(1) mydata <- data.frame(y = runif (100, min=...

The answer is simpler than I thought: histogram(A(:,1)) hold on histogram(A(:,2)) This automatically makes the bars transparent, so both can be seen....

mysql,sql,postgresql,histogram

Based upon your question, it is a simple select distinct and then an order by SELECT distinct(Column_Name) FROM Table_name ORDER BY Column_Name DESC Or SELECT distinct(Column_Name) FROM Table_name ORDER BY Column_Name Depending on the Sort order that you want...

The problem is that for both layers the cumulative sum is calculated over the whole x-axis. ggplot(df)+ geom_histogram(aes(x= POS, y=ifelse(x>=0, rev(cumsum(rev(..count..)))/4, 0)), binwidth = 1)+ geom_histogram(aes(x= NEG, y=ifelse(x<=0, cumsum(..count..)/4, 0)), binwidth = 1) ...

python,numpy,matplotlib,histogram

I do not know whether matplotlib allows this normalisation by default but I wrote a function to do it myself. It takes the output of n and bins from plt.hist (as above) and then passes this through the function below. def hist_norm_height(n,bins,const): ''' Function to normalise bin height by a...

matlab,statistics,time-series,histogram,fractals

Your code seems to be generally bug-free but I made some changes since you perform needless repetitions over loops (I moved the outer loop inside and "vectorized" it since all moment calculations can be performed simultaneously for a given histogram. Also, it is building the histogram that takes longest). intel...

python,matplotlib,plot,histogram

The picture shows a bar chart and not a histogram. I am pointing this out, not only because I am an obnoxious pedant, but also because I believe it could help you find the right tool :-) Indeed, for your purpose plt.bar is probably a better pick than plt.hist. Based...

After you have plotted the four graph, you can fix the left margin to the value it has at this momen, and adapt the right margin according to the different scales from graph four to graph five. You can calculate the left margin in screen coordinates (i.e. in the range...

One possibility would be to use a 'hollow histogram', as described here: # assign your original plot object to a variable p1 <- ggplot(data = dat, aes(x = values, linetype = category, fill = category)) + geom_histogram(colour = 'black', position = 'identity', alpha = 0.4, binwidth = 0.4) + scale_fill_grey()...

string,algorithm,sorting,streaming,histogram

The solution I came up with addresses the lack of up-front information about the population by using reservoir sampling. Reservoir sampling lets you efficiently take a random sample of a given size, from a population of an unknown size. See Wikipedia for more details. Reservoir sampling provides a random sample...

Here is the answer. ggplot(EF_Lat_Am, aes(x=V1, y = V4, fill=V3, width=.85)) + geom_bar(position="dodge", stat="identity") + labs(x = "", y = "EF (T/ha)") + theme(axis.text=element_text(size=16),axis.title=element_text(size=20), legend.title=element_text(size=20, face='bold'),legend.text=element_text(size=20), axis.line = element_line(colour = "black")) + scale_fill_grey("Period") + scale_y_continuous(limits=c(0,120)) + theme_classic(base_size = 20, base_family = "") ...

Forget about defining all those styles by hand and work within a loop instead: unset title set key left set yrange [0:10] set ylabel 'Score' set xtics rotate out set style histogram gap 1 set style data histogram set style fill solid 1.00 border 0 set xtics nomirror set ytics...

r,ggplot2,histogram,density-plot

the problem is that ggplot doesnt understand the data the way you input it, you need to reshape it like so (I am not a regex-master, so surely there are better ways to do is): df <- read.table(header = TRUE, text = " binRange Frequency 1 (0,0.025] 88 2 (0.025,0.05]...

Use fillstyle pattern to select between different fill patterns for each bar type, and lt -1 (or lc rgb 'black') to use black as line color: set terminal pngcairo set output "diskimage.png" set style data histograms plot 'Disk.txt' using 2:xtic(1) fs pattern 2 lt -1 title "Oct-09 data growth(gb)",\ ''...

matplotlib,line,histogram,curve

Using a kde did give me the plot I wanted, but in fact I would suggest using seaborn for this, as the module has a command distplot which plots a histogram and density plot at the same time. Examples of using seaborn given here: http://nbviewer.ipython.org/github/mwaskom/seaborn/blob/master/examples/plotting_distributions.ipynb...

Use the xticks function: plt.xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') ) Complete example (by the way, your code doesn't work for me, but instead of your error, I get TypeError: len() of unsized object, so I'm histogramming manually here): import matplotlib.pyplot as plt listofnames = ['Al', 'Ca', 'Re', 'Ma',...

So what is your actual problem with this? Using the histograms plotting should work fine. Consider the following data file A -1 1 -0.5 0.5 B -2 2 -1 1 C -3 3 -1.5 1.5 D -4 4 -2 2 E -5 5 -2.5 2.5 F -4 4 -2 2...

Using some simulated data this should get you what you want. The key is that you have to create your bivariate bins, accomplished using the cuts() function. Then treating the binned factors as levels we can then count the combinations of each factor level using the table() function: library(plot3D) ##...

python,list,python-2.7,dictionary,histogram

If you want to create you histogram with Matplotlib, you don't really need to do much more than call its hist method with each hat you want to show. For example, import pylab pylab.hist(data['hat4'][0], bins=(1,2,3,4), align='left') (You need to index at [0] because for some reason each of your dictionary...

The easiest way I can think of, is to summarise the results using table and then plot that summary: barplot(table(coins.2)) or if you wanted to stick to the density output, divide the summary by the total number of observations barplot(table(coins.2)/length(coins.2)) But please remember that there is a reason for histogram...

Here's an approach to create a histogram together with a density curve in ggplot2. The data: dat <- scan(textConnection("30.90 31.00 32.75 32.65 32.50 31.60 31.80 30.70 31.20 28.10 29.50 28.60 31.70 33.10")) The plot: library(ggplot2) qplot(dat, binwidth = 1.0, geom = "histogram", xlab = "Data", ylab = "Frequency", y =...

Note, that set style data histograms is ignored, because you overwrite it with the with boxes, and boxes and histograms are different ways to plot bar charts from the view point of grouping and arranging the data. If you can plot the first group with plot "t.dat" using 0:1 every...

I started typing this before the others showed up, so I'll post it anyway. This is probably nearly the most efficient (increasing efficiency would add some clutter) way of getting an answer, but it doesn't include code to ignore spaces, count characters without regard to case, etc (easy modifications). most_frequent(const...

python,pandas,matplotlib,histogram

This is a funny effect that appears to be present in pandas 0.16.0. Upgrading to 0.16.1 fixes it.

python,python-2.7,matplotlib,plot,histogram

As far as I know, matplotlib does not have this function built-in. However, it is easy enough to replicate import numpy as np heights,bins = np.histogram(data,bins=50) heights = heights/sum(heights) plt.bar(bins[:-1],heights,width=(max(bins) - min(bins))/len(bins), color="blue", alpha=0.5) Edit: Here is another approach from a similar question: weights = np.ones_like(data)/len(data) plt.hist(data, bins=50, weights=weights, color="blue",...

I usually use stopifnot() for this, so that you check the simplest condition first then proceed to the more complex; you don't want to test all of them at once if the first one is invalid: stopifnot(is.numeric(x)) stopifnot(is.factor(y)) stopifnot(length(x) == length(y)) Alternatively, doing all of this in one go: if(!(is.numeric(x)...

The hist.data.frame function from Hmisc does not have a parameter option for color. All of the calls to base hist() have no color parameters. A very hack-y workaround would be create your own hist.data.frame to temporarily redefine the hist() function and allow you to change the colors. For example hist.data.frame...

python,matplotlib,histogram,colorbar

You need to specify the color of the faces from some form of colormap, for example if you want 20 bins and a spectral colormap, nbins = 20 colors = plt.cm.spectral(np.linspace(nbins)) You can then use this to specify the color of the bars, which is probably easiest to do by...

Add amount and outcome1 to the for loop and clear output after each sum: for j in range (15): for i in range(10): output.append(probability(prob, outcome)) amount = sum(output) outcome1.append(amount) output = [] print(outcome1) ...

Something like hist(x, breaks = c(0, 500, 1000, 1500)) should do it. See ?hist....

I would try reading the data directly from the repo instead of saving it to a file first... library("httr") a <- GET("https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data") df <- read.csv(textConnection(content(a)), header=F) Histograms seems to work fine from here......

The reason they aren't the same is because you use imhist for im and hist for the blocks. Hist separates data into 10 different bins based on your data range, imhist separates data based on the image type. Since your arrays are doubles, the imhist bins are from 0 to...

It sounds like you just want to make sure that your x-axis values are numeric rather than factors ggplot(data=d1, aes(x=as.numeric(as.character(d.test)), y=Freq)) + geom_bar(stat="identity", width=.5) + geom_vline(xintercept=mean.score, color="blue", linetype="dashed") + scale_x_continuous(breaks=-2:3) which gives ...

If you just get the data from the hist function you can plot it in other, more flexible, ways. Is this more like what you want? OT = [124 124 124 125 125 125 126 249 249 250 250 250 312 312 312 438] binVals = unique(OT); histVals = hist(OT,...

r,ggplot2,histogram,category,density-plot

I made up some data for illustration: head(iris) table(iris$Species) df <- iris df$Species2 <- ifelse(df$Species == "setosa", "blue", ifelse(df$Species == "virginica", "red", "")) library(ggplot2) p <- ggplot(df, aes(x = Sepal.Length, colour = (Species == "setosa"))) p + geom_density() # Your example # Now let's choose the other created column p...

You can either fit the data that you get from a histogram using one of several ways: Use numpy.polufit for polynomial fits Use scipy.optimize.curve_fit for fitting arbitrary functions There is also kernel density approximation: scipy.stats.gaussian_kde which is a standard representation for most statsiticians. In seaborn, you can plot sns.kdeplot for...

python,matplotlib,histogram,gaussian

You probably want to use numpy to generate a Gaussian, and then simply plot it on the same axes. There is a good example here: Fitting a Gaussian to a histogram with MatPlotLib and Numpy - wrong Y-scaling? If you actually want to automatically generate a fitted gaussian from the...

Using global memory would solve the problem, but would not result in a very fast kernel. I suggest creating multiple work groups, and using each group to count a range of values only. #define RANGE_SIZE 8192 kernel void histo(__global uint data,__constant int dataSize){ int wid = get_local_id(0); int wSize =...

python,pandas,matplotlib,histogram

This is what you are after... I have added plt.ion() to bring it into interactive mode and plt.draw() to add each figure as you define it. By doing this it becomes obvious that the axis is defined as (y,x) not (x,y)... This reference might also help in the future import...

The problem is your x axis being continuous. Try this by using: library(ggplot2) ylim <- c(0, 1.1*max(plot_data$CLV)) ggplot(plot_data, aes(x=as.factor(CLV.decile), y=CLV)) + geom_histogram(stat="identity",fill="skyblue",colour="black") + labs(x="Decile",y="CLV") + geom_text(aes(label=CLV), vjust=-1) + ylim(ylim) + scale_x_discrete(limits=as.character(plot_data$CLV.decile)) You need to have CLV.decile as factor and then provide a scale_x_discrete to specify the order. And the bars...

Technically speaking, this is a barplot and not a histogram (histograms specifically refer to barplots used to represent binned frequencies of continuous variables) ... Your cbind() is messing things up (converting abatement and cost to factors): data <- data.frame(measure, abatement, cost) Here's a start: with(dplyr::arrange(data,cost), barplot(width=abatement,height=cost,space=0)) ...

One way is to use ggplot_build() and annotate(). You want to get values for x and y positions by creating a ggplot object once. Here, the object is g. When you use ggplot_build(objectname)$data[[1]], you can obtain the values you need. In annotate(), you use x and y values in foo...

Problem #1: c(x) and d(x) are lists of random numbers with a given distribution of probabilities. When you plot a histogram of c(x) or d(x), you are plotting the frequency of occurrence of each number. This frequency is just equal to the distribution. e(x) is a totally different object. You...

You can plot exactly as much of the histogram as you want by choosing a subsection of the matrix, bins = 100 xmin = 40 xmax = 60 [f,x]=hist(randn(1000000,1),bins); bar(x(xmin:xmax),f(xmin:xmax)) Alternatively, you can plot over a specified range of x bin values, xvalues = -1:0.1:0.9; [f,x]=hist(randn(1000000,1),xvalues); bar(x,f,'b') but all the...

java,arrays,histogram,repetition

First you compute the maximum height of the histogram. max=0; for(int i: repetition) if(i>max) max=i; Then, you print like this, from top to bottom: for(j=max;j>=1;j--){ //For each possible height of the histogram. for(k=0;k<repetition.length;k++) //Check height of each element if(repetition[k]>=j) System.out.print("*"); //Print * if the k-th element has at least a...

matlab,image-processing,plot,histogram

Assuming uint8 precision, each call to imhist will give you a 256 x 1 vector, and so you can concatenate these together into a single 768 x 1 vector. After, call bar with the histc flag. Assuming you have your image stored in im, do this: red = imhist(im(:,:,1)); green...

r,histogram,curve-fitting,gaussian

lines(density(rnorm(1000,mean=mean(f),sd = sd(f))),col=1,lwd=3)

python,pandas,matplotlib,histogram,attributeerror

Your question provide very poor information and insight in your code. More data.. Meanwhile check if you actually import your modules correctly, should have: import matplotlib.pyplot as plt in order to use hist function...

javascript,histogram,bar-chart,timeline,column-chart

Have a look at this code, you can replace categories(in x-axis) and data with your own arrays. <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> </head> <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"> </div> <script> $(function () { $('#container').highcharts({ chart: { type: 'column' }, title: { text: 'Column chart with...

With your data: myData <- data.frame(case = 1:48, group = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3), age = c(70,68,61,68,77,72,64,65,69,67,71,75,73,68,65,69,63,70,78,73,76,78,65,68,75,65,62,69,70,71,60,69,60,66,75,70,62,63,79,79,66,76,64,61,70,67,69,63), errors = c(9,6,7,8,10,11,4,5,5,6,12,8,9,3,7,6,8,6,12,7,13,10,8,8,11,5,9,6,9,6,9,7,5,3,6,6,7,5,9,8,6,6,3,4,7,5,4,5)) Here is the code you have to run in R: library(ggplot2) library(dplyr) myData %>% group_by(group)...

matlab,image-processing,histogram,distribution,vision

If you mean "distinguish" by "separate", then yes: The property you describe is called bimodality, i.e. you have 2 peaks that can be seperated by one threshold. So your question is actually "how do I test for an underlying bimodal distribution?" One option to do this programmatically is Binning. This...

Based on the OpenCV 2.4.9 source code: static inline std::ostream& operator << (std::ostream& out, const Mat& mtx) { Formatter::get()->write(out, mtx); return out; } Is the function you are calling when using << operator. Formatter::get() returns appropriate formatter class based on the programming language you are using. write() function basicly calls:...

smooth frequency renders the data monotonic in x (i.e. the value given in the first using column, in your case the numerical value from column 6), and then sums up all y-values (the values given in the second using column). Here you also give the the sixth column, which is...

See the code below. It uses the grDevices package. I can't remember for sure, but I think it comes with the base install. df <-read.csv("/Data/test1.csv") #read png(filename="output.png", width=1024, height=768) #open graphics df <- df[order(df$x),] #order data source mp <- barplot(df$y,axes=F) #plot w/o labels #add value labels text(cex=1.5, x=mp, y=df$y+par("cxy")[2]/2+1, round(df$y,2),...

You didn´t use quotes in your histogram list, but I am assuming that you wanted to plot a list of strings like ["a" "b" "c" ...], right? As far as I know, it is not possible to use categorical values (like strings) for a histogram in netlogo plots. This is...

python,list,histogram,typeerror,indices

That error is because you are trying to assign a key to a list, and list only can be indexed by intenger list[0], list[1], so on. So, hinstogram must be a dict not a list Make sure when you call add_to_hist method, pass a dict. You can init a dict...

upgrade comment. To get the border just add the colour="black" to the geom_bar call, in your first plot. A quick fix for the black line in the legend is to plot two geom_bar calls, suppressing the legend in the call with the border. You can then add a black border...

c++,opencv,image-processing,histogram

Some things I've noticed that might help: You declare H as follows: Mat H = Mat::zeros(1,512,CV_8UC1); Then you access it like so: H.at<uchar>(idx,1) = ... So you're creating a matrix with 1 row and 512 columns and then accessing row idx and column 1. You need to swap the indices...

In order to have ggplot2 showing a guide (a legend) you need to map something to the respective scale. This is done in aes (or aes_string in this case). color <- factor(color) library(ggplot2) m <- ggplot(returns.data.frame) + theme_bw() for (i in seq(1,3)) { m <- m + stat_bin( aes_string(x =...

matlab,histogram,kernel-density

The function hist gives you an approximation of the probability density you are evaluating. If you want a continuous representation of it, this article from the Matlab documentation explains how to get one using the spline command from the Curve Fitting Toolbox. Basically the article explains how to make a...

if you only need to do this for a handful of points, you could do something like this. If intensites and radius are numpy arrays of your data: bin_width = 0.1 # Depending on how narrow you want your bins def get_avg(rad): average_intensity = intensities[(radius>=rad-bin_width/2.) & (radius<rad+bin_width/2.)].mean() return average_intensities #...

Very easy with Pandas. import pandas from collections import Counter a = ['a', 'a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'd', 'e', 'e', 'e', 'e', 'e'] letter_counts = Counter(a) df = pandas.DataFrame.from_dict(letter_counts, orient='index') df.plot(kind='bar') Notice that Counter is making a frequency count, so our plot type is 'bar' not...

python,matplotlib,histogram,histogram2d

To extend @Tzach's comment, here's a minimal example to create a bar chart from your data: import matplotlib.pyplot as plt freq = {1: 1000, 2: 980, 4: 560, 40: 3, 41: 1, 43: 1} fig, ax = plt.subplots() ax.bar(freq.keys(), freq.values()) fig.savefig("bar.png") ...

Only you have two logical errors (1) calculating the threshold (2) add break in for, once found the range def histogram(data, num_bins): span = max(data) - min(data) bin_size = float(span) / num_bins thresholds = [0] * num_bins for i in range(num_bins): #I change thresholds calc thresholds[i] = min(data) + bin_size...

python,pandas,matplotlib,histogram,bar-chart

That's because the "hist" plot is not just plotting data, but actually first estimating the empirical distribution of the raw data and then plotting the result. That is, "hist" is going to bin the data, count the instances per bin and plot that, so there is no need of doing...

ios,objective-c,histogram,gpuimage,gpuimagestillcamera

To show histogram in separate view you need add another GPUImageView to your main view and point histogram filter to it. Here is source code based on SimpleImageFilter sample. - (void)loadView { CGRect mainScreenFrame = [[UIScreen mainScreen] applicationFrame]; GPUImageView *primaryView = [[GPUImageView alloc] initWithFrame:mainScreenFrame]; self.view = primaryView; UIImage *inputImage =...

python,dictionary,histogram,cumulative-sum,cumulative-frequency

The following should at least run (which your code as posted won't): import collections, itertools with open('text') as infile: letters = list(infile.read()) # not just letters: whitespace & punct, too letter_freqs = collections.Counter(letters) letter_sum = len(letters) letters_set = sorted(set(letters)) d = {l: letter_freqs[letter]/letter_sum for l in letters_set} cum = itertools.accumulate(d[l]...

"I do not understand what in the world this histogram is displaying." Well, as you said: "Histogram showing total number of dice rolls for each possible value" The histogram: 2: ****** 3: **** 4: *** 5: ******** 6: ******************* 7: ************* 8: ************* 9: ************** 10: *********** 11: *****...

Your code is obfuscating to me what your final result is supposed to be exactly. Maybe this: library(ggplot2) DF <- merge(xy.pop, xx.pop, by = "Var1") ggplot(DF, aes(y = Var1, xmin = -Freq.x, xmax = Freq.y, x = 0)) + geom_errorbarh() + geom_vline(xintercept = 0, size = 1.5) + theme_minimal() +...

python,matplotlib,histogram,bins

I am a bit confused with your data structure and how you are calling the function hist. However, I suppose you are using matplotib, so you need to define the same binning range for the hist function. It works better if you pass an array with the bin boundaries, instead...

java,elasticsearch,max,histogram,aggregation

I think I found a solution: $ curl -XGET 'http://localhost:9200/localhost.localdomain/SET_APPS/_search?pretty=true' -d' { "aggregations" : { "time_hist" : { "histogram" : { "field" : "time", "interval" : 10125000, "order" : { "_count" : "asc" }, "min_doc_count" : 0, "extended_bounds" : { "min" : 1429010378445, "max" : 1431602378445 } }, "aggregations" :...

As Backlin commented above, you can use the par() function and mfrow option to control subplots: par(mfrow=c(2,2)) hist(iris$Sepal.Width) hist(iris$Sepal.Length) hist(iris$Petal.Width) hist(iris$Petal.Length) ...

I think the code below will work. In short, I determine the densities of each vector, approx to some known vector of x values, jam it all together in a matrix, and then calculate the summary stats and plot. Is this what you were looking to do? #Make up some...

python,pandas,matplotlib,histogram

You don't want to do a histogram of those values, you just want to plot them as-is. Try: firstperiod.megaball.value_counts().sort_index().plot(kind='bar') You may have to fiddle with other plot options to get the plot to look exactly how you want....

python,image-processing,numpy,histogram

Moose's comment which points to this blog entry does the job quite nicely. For completeness I give an axample here using nicer variable names and a looped execution on 1000 96x96 images which are in a 4D array as in the question. It is fast (1-2 seconds on my computer)...

smooth histogram this filter out small local min max and noise use symmetric smoothing to avoid shifting to one side I smooth from left then from the right which lower the shifting a lot find/count the local max peaks count only big enough peaks (by some treshold) if peak...

From the code in your question, it looks like you're using numpy. There are better ways to approach this problem in numpy, and I'll go over those at the end of the answer. For the moment, though, let's look at why what you tried didn't work. The reason that it's...

python,pandas,matplotlib,histogram,logarithm

You could use ax.set_xscale('log') data.hist() returns an array of axes. You'll need to call ax.set_xscale('log') for each axes, ax to make each of the logarithmically scaled. For example, import numpy as np import pandas as pd import matplotlib.pyplot as plt np.random.seed(2015) N = 100 arr = np.random.random((N,2)) * np.logspace(-2,2,N)[:, np.newaxis]...

r,if-statement,colors,ggplot2,histogram

It would be easiest to just add another column with the condition and update the aes to include the fill group. cust$high_rev <- as.factor((cust[,2]>100000)*1) ggplot(cust, aes(cust_rev, fill=high_rev)) + geom_histogram(color="black", binwidth=1/3) + scale_x_log10(labels=comma, breaks=powers(10,8)) + scale_y_continuous(labels=comma) + xlab("Customer Revenue") + ylab("Number of Customers") + ggtitle("Distribution of Customer Value") If you have...