histogram

Pandas histogram df.hist() group by

≡放荡痞女 提交于 2019-12-03 16:29:18
问题 How to plot a histogram with pandas DataFrame.hist() using group by? I have a data frame with 5 columns: "A", "B", "C", "D" and "Group" There are two Groups classes: "yes" and "no" Using: df.hist() I get the hist for each of the 4 columns. Now I would like to get the same 4 graphs but with blue bars (group="yes") and red bars (group = "no"). I tried this withouth success: df.hist(by = "group") 回答1: This is not the most flexible workaround but will work for your question specifically. def

Binning an array in javascript for a histogram

天涯浪子 提交于 2019-12-03 16:26:47
I have below array in Javascript which I need to bin into 20 buckets. The data values are between 0 and 1, so the bin size would be .05. I feel like there should be a function out there that takes two arguments, an array and a bin size, but I cannot find one. I know that D3.js has some feature that help building such an array, but I cannot figure out which function might help. var arr = [ "0.362743", "0.357969", "0.356322", "0.355757", "0.358511", "0.357218", "0.356696", "0.354579", "0.828295", "0.391186", "0.378577", "0.39372", "0.396416", "0.395641", "0.37573", "0.379666", "0.377443", "0

changing default x range in histogram matplotlib

不羁的心 提交于 2019-12-03 16:16:26
问题 I would like to change the default x range for the histogram plot. The range of the data is from 7 to 12. However, by default the histogram starts right at 7 and ends at 13. I want it to start at 6.5 and end at 12.5. However, the ticks should go from 7 to 12.How do I do it? import asciitable import numpy as np import matplotlib.pyplot as plt import matplotlib.mlab as mlab import pylab from pylab import xticks data = asciitable.read(file) hmag = data['col8'] visits = data['col14'] origin =

CIAreaHistogram inputScale factor

安稳与你 提交于 2019-12-03 15:30:45
I'm building an application that uses the CIAreaHistogram Core Image filter. I use an inputCount value (number of buckets) of 10 for testing, and an inputScale value of 1. I get the CIImage for the histogram itself, which I then run through a custom kernel (see end of post) to set alpha values to 1 (since otherwise the alpha value from the histogram calculations is premultiplied) and then convert it to an NSBitmapImageRep . I then scan through the image rep's buffer and print the RGB values (skipping the alpha values). However, when I do this, the sum of the R, G, and B values across the 10 do

how can I visualize a histogram with promdash or grafana

旧巷老猫 提交于 2019-12-03 15:11:45
问题 I'm attracted to prometheus by the histogram (and summaries) time-series, but I've been unsuccessful to display a histogram in either promdash or grafana. What I expect is to be able to show: a histogram at a point in time, e.g. the buckets on the X axis and the count for the bucket on the Y axis and a column for each bucket a stacked graph of the buckets such that each bucket is shaded and the total of the stack equals the inf bucket A sample metric would be the response time of an HTTP

Generating a histogram from column values in a database

女生的网名这么多〃 提交于 2019-12-03 14:48:57
问题 Let's say I have a database column 'grade' like this: |grade| | 1| | 2| | 1| | 3| | 4| | 5| Is there a non-trivial way in SQL to generate a histogram like this? |2,1,1,1,1,0| where 2 means the grade 1 occurs twice, the 1s mean grades {2..5} occur once and 0 means grade 6 does not occur at all. I don't mind if the histogram is one row per count. If that matters, the database is SQL Server accessed by a perl CGI through unixODBC/FreeTDS. EDIT: Thanks for your quick replies! It is okay if non

Histogram on Lattice

ⅰ亾dé卋堺 提交于 2019-12-03 14:38:34
Since hist() of the base R does not report percentages (and the freq=FALSE) does not help either, I turned to lattice . histogram(rnorm(10000)) Please help me with the following: How can I get rid of the box arround the plot? How can I seperately define the cex of the x/y labels and x/y axis? How can I provide custom names to x and y axis? This should get you started: library(lattice) histogram(rnorm(10000), main=list( label="Main plot title", cex=1.5), xlab=list( label="Custom x-axis label", cex=0.75), ylab=list( label="My very own y-axis label", cex=1.2), scales=list(cex=0.5), par.settings =

Turn hist2d output into contours in matplotlib

一曲冷凌霜 提交于 2019-12-03 14:22:54
I have generated some data in Python using matplotlib.hist2d. An example of the data is seen below. As you can see this data has some contours in it found by tracing the same color throughout the plot. I see a gamma distribution centered around 0.015. I would like to take this data and gather these contours so I can see a line trace through each color level. I tried playing around with the contour function as here counts, xedges, yedges, Image = hist2d(x, y, bins=bins, norm=LogNorm(), range=[[0, 1], [0, 400]]) contour(counts) but that didn't seem to produce anything. Does anyone know the best

Selecting best range of values from histogram curve

纵饮孤独 提交于 2019-12-03 13:50:29
Scenario : I am trying to track two different colored objects. At the beginning, user is prompted to hold the first colored object (say, may be a RED) at a particular position in front of camera (marked on screen by a rectangle) and press any key, then my program takes that portion of frame (ROI) and analyze the color in it, to find what color to track. Similarly for second object also. Then as usual, use cv.inRange function in HSV color plane and track the object. What is done : I took the ROI of object to be tracked, converted it to HSV and checked the Hue histogram. I got two cases as below

Time-series histogram

江枫思渺然 提交于 2019-12-03 13:42:41
问题 Is it possible to create a time-series histogram like the one described in this presentation (slides 36-39) using either R or D3.js? Or is there a better way to show bucketed data as a time series? Edit: Here is some pre-bucketed sample data. Ideally, D3 or R would do the bucketing by itself. And yes, if it wasn't clear, I understand that I could write this myself. I'm just wondering if there's already a package that does this and I just haven't come across it yet. Thanks! 回答1: Here is one