histogram

matplotlib: How can you specify colour levels in a 2D historgram

落花浮王杯 提交于 2019-12-04 08:12:01
I would like to plot a 2D histogram that includes both positive and negative numbers. I have the following code which uses pcolormesh but I am unable to specify the color levels to force the white color to corresponds to zero (i.e., I want my colorbar to be symmetric around zero). I've also tried imshow. I know you can specify colour levels in plt.contour and plt.contourf but I can't find a way to plot the 2D histogram using blocks. Any advice would be greatly appreciated. import numpy as np import matplotlib.pyplot as plt from matplotlib import cm as CM fig = plt.figure() # create an example

Get a histogram plot of factor frequencies (summary)

非 Y 不嫁゛ 提交于 2019-12-04 08:06:24
问题 I've got a factor with many different values. If you execute summary(factor) the output is a list of the different values and their frequency. Like so: A B C D 3 3 1 5 I'd like to make a histogram of the frequency values, i.e. X-axis contains the different frequencies that occur, Y-axis the number of factors that have this particular frequency. What's the best way to accomplish something like that? edit: thanks to the answer below I figured out that what I can do is get the factor of the

Similar image search using an image

…衆ロ難τιáo~ 提交于 2019-12-04 07:43:02
I am working on a project in which the two images will be checked for similarity like 'Google Image Search by image'. I searched through Google and also on various sites including stackoverflow and learnt about various techniques like histogram, sift, fourier transform, pixel grabbing, etc. The things are too complex for me to understand being a beginner in this field. My questions are: From where can i get started?? Is there any book available or a site which give tutorials for learning about how to actually use these techniques? Are there new techniques which can be implemented for this

Histogram with marginal boxplot in R

扶醉桌前 提交于 2019-12-04 07:25:31
How make matching X-axis in histogram with marginal boxplot? data <- rnorm(1000) nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,3)) layout.show(nf) par(mar=c(5.1, 4.1, 1.1, 2.1)) boxplot(data, horizontal=TRUE, outline=FALSE) hist(data) One solution would be to set ylim= in boxplot() to the same range as xlim= in hist() . set.seed(123) data <- rnorm(1000) nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,3)) par(mar=c(5.1, 4.1, 1.1, 2.1)) boxplot(data, horizontal=TRUE, outline=FALSE,ylim=c(-4,4)) hist(data,xlim=c(-4,4)) Using ggplot and grid package. library

How to get a three-dimensional histogram from two-dimensional data?

浪尽此生 提交于 2019-12-04 06:01:36
问题 I have two data lists: x=[2006, 2007, 2008, 2009, 2010] y=[700, 560, 450, 500, 570] I needed to build a regular histogram (it was not difficult). But I also need a three-dimensional diagram, as in the figure . I tried various options (for example, bar3d), but it turns out not that. Help, please. import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x= [float(i) for i in input('Input x ').split()] y= [float(i) for i in input('Input y '

Any way to create histogram with matplotlib.pyplot without plotting the histogram?

人盡茶涼 提交于 2019-12-04 05:54:30
I am using matplotlib.pyplot to create histograms. I'm not actually interested in the plots of these histograms, but interested in the frequencies and bins (I know I can write my own code to do this, but would prefer to use this package). I know I can do the following, import numpy as np import matplotlib.pyplot as plt x1 = np.random.normal(1.5,1.0) x2 = np.random.normal(0,1.0) freq, bins, patches = plt.hist([x1,x1],50,histtype='step') to create a histogram. All I need is freq[0] , freq[1] , and bins[0] . The problem occurs when I try and use, freq, bins, patches = plt.hist([x1,x1],50,histtype

Define bar chart colors for Pandas/Matplotlib with defined column

风流意气都作罢 提交于 2019-12-04 05:27:12
问题 I have a dataframe "table" like this: SAMPLE RANK VALUE CAT 3 N DOG 1 N FISH 4 Y ANT 2 N HORSE 5 N How can I JUST COLOR the 3rd histogram column, given that there is a "Y" in the VALUE column? I would like it to look like this: So far I have : table.plot('SAMPLE','RANK', hue="VALUE", palette={"Y": "r", "N": '0.75'}, kind='bar') but this does not work 回答1: You may achieve the desired effect by mapping VALUE column to desired colors: colors = {'N':'#00BEC5', 'Y':'#F9746A'} df.sort_values('RANK'

gnuplot histogram errorbar problems

你。 提交于 2019-12-04 04:38:20
问题 Summary I'm trying to use error bars with gnuplot but am running into two problems. The first problem is that the error bars are not correctly aligned. The second problem is that I can't specify multiple data sets when using error bars. First problem: error bar alignment The first problem is that the error bars are not correctly aligned as can be seen in the following image: This image was generated from the following script: set terminal postscript eps enhanced set yrange [0:20] set style

count specific characters in a string (Java)

本秂侑毒 提交于 2019-12-04 03:05:42
问题 I have a homework assignment to count specific chars in string. For example: string = "America" The output should be = a appear 2 times, m appear 1 time, e appear 1 time, r appear 1 time, i appear 1 time and c appear 1 time public class switchbobo { /** * @param args */ // TODO Auto-generated method stub public static void main(String[] args){ String s = "BUNANA"; String lower = s.toLowerCase(); char[] c = lower.toCharArray(); // converting to a char array int freq =0, freq2 = 0,freq3 = 0

matplotlib: histogram and bin labels

寵の児 提交于 2019-12-04 02:38:12
I'm trying to plot a histogram with bar chart, and I'm having difficulties figuring out how to align the x-axis labels with the actual bins. The code below generates the following plot: as you can see, the end of each x-label is not aligned to the center of its bin. The way i'm thinking about this is: when i apply a 45-degree rotation, the label pivots around its geometrical center. I was wondering if it's possible to move the pivot up to the top of the label. (Or simply translate all the labels slightly left.) import matplotlib.pyplot as plt import numpy as np #data np.random.seed(42) data =